View Source Sptfy.OAuth (Sptfy v0.1.5)
This provides functions to obtain authorization with authorization code flow.
Link to this section Summary
Functions
Requests access token and refresh token to the Spotify Accounts service.
Exchanges a refresh token for new access token.
Returns a URL to request an authorization code.
Link to this section Types
@type response() :: {:ok, Sptfy.Object.OAuthResponse.t()} | {:error, Sptfy.Object.OAuthError.t()} | {:error, Mint.Types.error()}
Link to this section Functions
@spec get_token( client_id :: String.t(), client_secret :: String.t(), code :: String.t(), redirect_uri :: String.t() ) :: response()
Requests access token and refresh token to the Spotify Accounts service.
@spec refresh_token( client_id :: String.t(), client_secret :: String.t(), refresh_token :: String.t() ) :: response()
Exchanges a refresh token for new access token.
@spec url( client_id :: String.t(), redirect_uri :: String.t(), params :: map() | Keyword.t() ) :: String.t()
Returns a URL to request an authorization code.
iex> Sptfy.OAuth.url("CLIENT_ID", "https://example.com/callback")
...> "https://accounts.spotify.com/authorize?client_id=CLIENT_ID&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&response_type=code&scope="
iex> Sptfy.OAuth.url("CLIENT_ID", "https://example.com/callback", %{scope: ["streaming"]})
...> "https://accounts.spotify.com/authorize?client_id=CLIENT_ID&redirect_uri=https%3A%2F%2Fexample.com%2Fcallback&response_type=code&scope=streaming"