Class TokenExchangeRequest

java.lang.Object
com.spotify.sdk.android.auth.TokenExchangeRequest

public class TokenExchangeRequest extends Object
A utility class for exchanging an authorization code for an access token using PKCE verifier. This implements the OAuth 2.0 Authorization Code Grant with PKCE as specified in RFC 7636.
  • Constructor Details

    • TokenExchangeRequest

      public TokenExchangeRequest(@NonNull String clientId, @NonNull String code, @NonNull String redirectUri, @NonNull String codeVerifier)
      Creates a new token exchange request.
      Parameters:
      clientId - The client ID of the application
      code - The authorization code received from the authorization server
      redirectUri - The redirect URI used in the authorization request
      codeVerifier - The PKCE code verifier that was used to generate the code challenge
  • Method Details

    • execute

      @NonNull public TokenExchangeResponse execute()
      Executes the token exchange request synchronously. This method performs a blocking HTTP request and should not be called on the main thread.
      Returns:
      TokenExchangeResponse containing the access token or error information