Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a way to create a PlanetScale Client using the same auth method as the CLI #175

Open
mattrobenolt opened this issue Aug 15, 2023 · 1 comment

Comments

@mattrobenolt
Copy link
Member

mattrobenolt commented Aug 15, 2023

From within planetscale/cli, everything as far as reading a config file and yanking an access token out of the OS keyring is locked away in internal packages internal to the CLI.

If I want to use this library in code, in theory, I'd like to instantiate a client that leverages my system's auth in a similar fashion. Whether this is fully depending on the config file pscale CLI writes, or just sharing some mechanism to yank an already auth'd token out of the keyring would be super nice.

This would allow tooling outside of pscale to "just work" without requiring use of the CLI.

Maybe just necessary for the keyring access being one of the constructor arguments?

client, err := planetscale.NewClient(
	planetscale.WithSystemKeyring(...),
)

or something similar is what I'm thinking. I'd like to leverage this rather than extract it and set it as an env var or pass as a flag to something else.

Thoughts?

@mattrobenolt
Copy link
Member Author

I think this sorta is not something possible since Keychain access is heavily restricted by binaries. So given that, I guess I don't see any way for other tools to leverage an existing access-token or logged in session from the pscale CLI. And you always need your own service token or unique oauth app.

Wonder if there's a middleground possible for the CLI to provide something like, pscale print-env that dumps out auth creds that can be easily sourced into your env.

But I might be stretching now, just found it a bit unintuitive that I wasn't able to leverage my already logged in session.

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

No branches or pull requests

1 participant