Closed strideynet closed 2 years ago
I think it would be a great idea adding again this function in v2:
// Token gets the client's current token.
func (c *Client) Token() (*oauth2.Token, error) {
transport, ok := c.http.Transport.(*oauth2.Transport)
if !ok {
return nil, errors.New("spotify: oauth2 transport type not correct")
}
t, err := transport.Source.Token()
if err != nil {
return nil, err
}
return t, nil
}
The main reason behind this proposal is that, when you create a new spotify.Client
with OAuth credentials that are expired, you will receive a new token. But because this newly returned token is stored inside spotify.Client.http
, you have no access to the object variable from outside and are not able to store it in case the app exits.
Hi @strideynet, I just saw that this Issue is still open but was resolved by PR #170 :)
Thanks Elivlo
Developers may wish to capture the currently active access/refresh tokens, rather than persisting the original tokens after the oauth2 flow completes.
Assists #168