Spotify - Client Credentials flow (via manual header)
POST https://accounts.spotify.com/api/token
From the Spotify Authorization Guide, follow one of 3 optional flows to obtain app authorization.
Refreshable app authorization: Client Credentials
The Client Credentials flow is used in server-to-server authentication. Only endpoints that do not access user information can be accessed.
You do: Login with your Client ID and Secret Key
You get: Access token
This method uses https://accounts.spotify.com/api/token
.
In Qodex
Under the Headers tab, add an Authorization
header with a placeholder for a value of Basic {{encodedIdAndKey}}
. The variable encodedIdAndKey
is currently unresolved. Let's define this variable in the next step.
](/assets/blogs/https://i.imgur.com/W6OYi94.png)
Under the Pre-request Script tab, encode your spotify_client_id
and spotify_client_secret
to Base64, and then set a local variable called encodedIdAndKey
so you can use it in the Header. When you Send the request, Qodex will attach the encoded header.
](/assets/blogs/https://i.imgur.com/t9fqNeK.png)
This request shows how to manually add a header in Qodex. The previous request was an example of how to do this by using the Authorization helper.
Request Body
[{"name"=>"grant_type", "value"=>"client_credentials", "datatype"=>"string"}]
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Authorization | string |
RESPONSES
status: OK
{"access_token":"BQAHVkZFKuMbhSYNA6wYqAwnOv9lIAQXMGyh2C2Upj7H5o6RpafUa30fqoR2w5ssOu9bq6DhQnL0fGjJfss","token_type":"Bearer","expires_in":3600,"scope":""}