I'm working on an MCP client and using the new OAuth2 functionality in the v1.5.0 pre-release has worked well for me!
However, I have found an area of the API that I'm having to hack around and I'm not sure if it is a missing feature or if I'm just missing something.
My client stores the oauth2.Token locally so it can load it on start for use by the mcp client. I want to hook the automatic refresh of the token so that I can store the updated access and refresh token in my client state on disk. What is the best way to achieve this?
Right now I'm using a custom AuthorizationCodeHandlerConfig.Client that intercepts the refresh request but it feels very hacky. Would appreciate any advice. Thanks!
edit: Similarly, I would like to be able to extract the ClientID, ClientSecret, and token Endpoint so that I can reconstruct a oauth2.Config object.
https://pkg.go.dev/golang.org/x/oauth2#Config
I'm working on an MCP client and using the new OAuth2 functionality in the v1.5.0 pre-release has worked well for me!
However, I have found an area of the API that I'm having to hack around and I'm not sure if it is a missing feature or if I'm just missing something.
My client stores the
oauth2.Tokenlocally so it can load it on start for use by the mcp client. I want to hook the automatic refresh of the token so that I can store the updated access and refresh token in my client state on disk. What is the best way to achieve this?Right now I'm using a custom
AuthorizationCodeHandlerConfig.Clientthat intercepts the refresh request but it feels very hacky. Would appreciate any advice. Thanks!edit: Similarly, I would like to be able to extract the
ClientID,ClientSecret, and tokenEndpointso that I can reconstruct aoauth2.Configobject.https://pkg.go.dev/golang.org/x/oauth2#Config