oauth2 icon indicating copy to clipboard operation
oauth2 copied to clipboard

Make RetrieveToken usable by client packages

Open mholt opened this issue 6 years ago • 4 comments

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.

https://github.com/golang/oauth2/blob/c453e0c757598fd055e170a3a359263c91e13153/token.go#L154

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 avatar Dec 20 '18 14:12 mholt

Figured out another way to do this in the meantime

mholt avatar Dec 28 '18 15:12 mholt

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

pacoguzman avatar Jun 06 '23 15:06 pacoguzman

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

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. :man_shrugging:

mholt avatar Jun 06 '23 16:06 mholt

Thank you for your response, I've reused existing API and write some comments about it to my future self.

On Tue, Jun 6, 2023, 18:28 Matt Holt @.***> wrote:

Reopened #354 https://github.com/golang/oauth2/issues/354.

— Reply to this email directly, view it on GitHub https://github.com/golang/oauth2/issues/354#event-9448433369, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAACVLV6FX5UREKULX3GUQTXJ5LDLANCNFSM4GLRKGVQ . You are receiving this because you commented.Message ID: @.***>

pacoguzman avatar Jun 10 '23 12:06 pacoguzman