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

auth_code_pkce: add from_token_with_config() constructor #512

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

gdesmott
Copy link
Contributor

Description

Add AuthCodePkceSpotify::from_token_with_config()

Motivation and Context

This is required to be able to refresh an expired token from the cache as we need the client ID to refresh the token.

Fix #511

Dependencies

None

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

  • Call a AuthCodePkceSpotify using with_config() and
Config {
        token_cached: true,
        token_refreshing: true,
        ..Default::default()
    };
  • Authenticate using the normal flow.
  • Terminate the app and wait for one hour for the token to expired.
  • Restore the token using Token::from_cache() and check that token.is_expired() returns true.
  • Create a client with AuthCodePkceSpotify::from_token() and then call client.refresh_token(). The client won't work as the token has not been refresh. You can also check by calling client.refetch_token() as it returns None.
  • Now create a client using AuthCodePkceSpotify::from_token_with_config() passing the proper Credentials. client.refresh_token() and client.refetch_token() are now working.

Is this change properly documented?

Yes.

This is required to be able to refresh an expired token from the cache
as we need the client ID to refresh the token.

Fix ramsayleung#511
@ramsayleung
Copy link
Owner

thanks for your contribution :)

@ramsayleung ramsayleung merged commit a12694f into ramsayleung:master Dec 29, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

No way to create AuthCodePkceSpotify from token with config
2 participants