Skip to content

Conversation

@andrii-balitskyi
Copy link
Contributor

@andrii-balitskyi andrii-balitskyi commented Apr 25, 2024

Enable authenticating Seam client with PAT. Add Seam.from_personal_access_token and Seam.from_api_key static methods.

@razor-x
Copy link
Member

razor-x commented Apr 26, 2024

The publishable_key, client session, and console session auth are only used from a browser context and thus will only be used by the JS SDK.

api_key="seam_at1_shorttoken_longtoken",
endpoint=f"https://{r}.fakeseamconnect.seam.vc",
personal_access_token="seam_at1_shorttoken_longtoken",
workspace_id="seed_workspace_1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting: Creating a workspace should not be allowed when using a PAT and a workspace ID.

Copy link
Contributor Author

@andrii-balitskyi andrii-balitskyi Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix the endpoint then. What type of auth should be allowed?

Copy link
Member

@razor-x razor-x May 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auth on that endpoint is PAT without a Workspace. This is correct, since a PAT with a workspace cannot operate or create resources outside of the workspace.

The JS SDK handles this by omitting the method from the Seam class but allowing it for SeamMultiWorkspaces

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side node, I realize now that the name SeamHttpWorkspaces implies that operations should work for different workspaces, but it really needs to mean the client only provides operations that are "workspace less". Maybe we can think of a better name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. So what approach should we take in Python SDK? Ignore /workspaces/create on Seam client and add SeamMultiWorkspace client that will support that endpoint and allow passing PAT without workspace?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes 😀

Copy link
Member

@razor-x razor-x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Two main things:

  1. Let's add the parse_options function, see https://github.com/seamapi/javascript-http/blob/main/src/lib/seam/connect/parse-options.ts#L31-L85
  2. We should require the workspace_id when using PAT and introduce SeamMultiWorkspace class in another PR.

Copy link
Member

@razor-x razor-x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a few last comments :)

Copy link
Member

@razor-x razor-x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to include in the generator now. Let's export any other custom errors in the generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants