- __construct
- generateCodeChallenge
- generateCodeVerifier
- generateState
- getAuthorizeUrl
- getAccessToken
- getClientId
- getClientSecret
- getTokenExpiration
- getRedirectUri
- getRefreshToken
- getScope
- refreshAccessToken
- requestAccessToken
- requestCredentialsToken
- setAccessToken
- setClientId
- setClientSecret
- setRedirectUri
- setRefreshToken
Session::__construct($clientId, $clientSecret, $redirectUri, $request)
Constructor
Set up client credentials.
$clientId
string - The client ID.$clientSecret
string - Optional. The client secret.$redirectUri
string - Optional. The redirect URI.$request
\SpotifyWebAPI\Request - Optional. The Request object to use.
Session::generateCodeChallenge($codeVerifier, $hashAlgo)
Generate a code challenge from a code verifier for use with the PKCE flow.
$codeVerifier
string - The code verifier to create a challenge from.$hashAlgo
string - Optional. The hash algorithm to use. Defaults to "sha256".
- string The code challenge.
Session::generateCodeVerifier($length)
Generate a code verifier for use with the PKCE flow.
$length
int - Optional. Code verifier length. Must be between 43 and 128 characters long, default is 128.
- string A code verifier string.
Session::generateState($length)
Generate a random state value.
$length
int - Optional. Length of the state. Default is 16 characters.
- string A random state value.
Session::getAuthorizeUrl($options)
Get the authorization URL.
$options
array|object - Optional. Options for the authorization URL.- string code_challenge Optional. A PKCE code challenge.
- array scope Optional. Scope(s) to request from the user.
- boolean show_dialog Optional. Whether or not to force the user to always approve the app. Default is false.
- string state Optional. A CSRF token.
- string The authorization URL.
Session::getAccessToken()
Get the access token.
- string The access token.
Session::getClientId()
Get the client ID.
- string The client ID.
Session::getClientSecret()
Get the client secret.
- string The client secret.
Session::getTokenExpiration()
Get the access token expiration time.
- int A Unix timestamp indicating the token expiration time.
Session::getRedirectUri()
Get the client's redirect URI.
- string The redirect URI.
Session::getRefreshToken()
Get the refresh token.
- string The refresh token.
Session::getScope()
Get the scope for the current access token
- array The scope for the current access token
Session::refreshAccessToken($refreshToken)
Refresh an access token.
$refreshToken
string - Optional. The refresh token to use.
- bool Whether the access token was successfully refreshed.
Session::requestAccessToken($authorizationCode, $codeVerifier)
Request an access token given an authorization code.
$authorizationCode
string - The authorization code from Spotify.$codeVerifier
string - Optional. A previously generated code verifier. Will assume a PKCE flow if passed.
- bool True when the access token was successfully granted, false otherwise.
Session::requestCredentialsToken()
Request an access token using the Client Credentials Flow.
- bool True when an access token was successfully granted, false otherwise.
Session::setAccessToken($accessToken)
Set the access token.
$accessToken
string - The access token
- self
Session::setClientId($clientId)
Set the client ID.
$clientId
string - The client ID.
- self
Session::setClientSecret($clientSecret)
Set the client secret.
$clientSecret
string - The client secret.
- self
Session::setRedirectUri($redirectUri)
Set the client's redirect URI.
$redirectUri
string - The redirect URI.
- self
Session::setRefreshToken($refreshToken)
Set the session's refresh token.
$refreshToken
string - The refresh token.
- self