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

Make RetrieveToken usable by client packages #354

Open
mholt opened this issue Dec 20, 2018 · 4 comments
Open

Make RetrieveToken usable by client packages #354

mholt opened this issue Dec 20, 2018 · 4 comments

Comments

@mholt
Copy link

mholt commented Dec 20, 2018

I'm working on a client that needs to refresh tokens in a special way, so I'm implementing my own TokenSource. The strange thing seems to be that, although the TokenSource interface is exported, I can't actually reuse the provided logic to refresh a token, as retrieveToken is unexported and it calls an internal-only function: internal.RetrieveToken(), even though all the parameters are exported values too.

oauth2/token.go

Line 154 in c453e0c

tk, err := internal.RetrieveToken(ctx, c.ClientID, c.ClientSecret, c.Endpoint.TokenURL, v)

I'd like to use either retrieveToken() or internal.RetrieveToken() as I'm essentially wrapping it differently than the built-in token refresher.

Can we potentially export retrieveToken() or make internal.RetrieveToken() usable by external packages?

@mholt
Copy link
Author

mholt commented Dec 28, 2018

Figured out another way to do this in the meantime

@mholt mholt closed this as completed Dec 28, 2018
@pacoguzman
Copy link

I'm trying to do something similar, what was your way to do it if you can share it?

@mholt
Copy link
Author

mholt commented Jun 6, 2023

Uhhh wow, 5 years ago, I don't really remember 😅

I think I was working on this project at the time, so you may find some hints in this file: https://github.com/mholt/timeliner/blob/cf155164e218ca1ad6ad600152cd2436c88dba43/oauth2.go#L41 -- not 100% sure it worked correctly but I think it did work for me. 🤷‍♂️

@mholt mholt reopened this Jun 6, 2023
@pacoguzman
Copy link

pacoguzman commented Jun 10, 2023 via email

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

2 participants