Authorization Apis
class AuthorizationApis(client: HttpClient = HttpClient(CIO) {
install(ContentNegotiation) {
json()
}
}, authorizeEndpoint: String = "https://accounts.spotify.com/authorize", tokenEndpoint: String = "https://accounts.spotify.com/api/token")
Spotify Accounts authorization API.
Provides Authorization Code, PKCE, Client Credentials, and Refresh Token requests.
Functions
Link copied to clipboard
Link copied to clipboard
fun buildAuthorizationCodeWithPkceUri(clientId: String, redirectUri: String, codeChallenge: String, codeChallengeMethod: String = "S256", scope: List<String> = emptyList(), state: String? = null, showDialog: Boolean? = null): String
Builds the Spotify Accounts authorization URL for Authorization Code with PKCE flow.
Link copied to clipboard
suspend fun refreshToken(clientId: String, clientSecret: String, refreshToken: String): SpotifyApiResponse<TokenResponse>
Refreshes an access token for Authorization Code flow.
Link copied to clipboard
suspend fun refreshTokenWithPkce(clientId: String, refreshToken: String): SpotifyApiResponse<TokenResponse>
Refreshes an access token for Authorization Code with PKCE flow.
Link copied to clipboard
suspend fun requestAuthorizationCodeToken(clientId: String, clientSecret: String, code: String, redirectUri: String): SpotifyApiResponse<TokenResponse>
Exchanges an authorization code for access and refresh tokens.
Link copied to clipboard
suspend fun requestAuthorizationCodeWithPkceToken(clientId: String, code: String, redirectUri: String, codeVerifier: String): SpotifyApiResponse<TokenResponse>
Exchanges an authorization code for access and refresh tokens using PKCE.
Link copied to clipboard
suspend fun requestClientCredentialsToken(clientId: String, clientSecret: String): SpotifyApiResponse<TokenResponse>
Requests an app-only access token using Client Credentials flow.