In this guide:
Okta Workflows guides
Okta Workflows guides are questions and answers from the community office hours, the #okta-workflows channel on MacAdmins Slack, and other places. Read all the other guides.
How do you call Spotify API that uses OAuth authentication from Okta Workflows?
This guide will teach you how to call Spotify API, which uses OAuth authentication from Okta Workflows. You can use this example to call other APIs that use OAuth authentication.
Call Spotify API
You want to call Spotify’s Get Current User’s Playlists API.
This is how the curl request looks:
curl --request GET \
--url https://api.spotify.com/v1/me/playlists \
--header 'Authorization: Bearer <access_token>'
Create a Spotify account
- Create a Spotify account, if you don’t have one.
Create an app
An app will provide an access token to make calls to Spotify API.
- Create an app.
- For the Redirect URIs field, use the following redirect URIs to connect to Okta Workflows:
- Okta Workflows Preview:
https://oauth.workflows.oktapreview.com/oauth/httpfunctions/cb
- Okta Workflows Production:
https://oauth.workflows.okta.com/oauth/httpfunctions/cb
- Okta Workflows Preview:
This is how the app looks when using the Okta Workflows Preview callback URI:

In the following section, you will create a connection in Okta Workflows with information from this app.
Create a connection
- Go to the Connections page in Okta Workflows.
- To create a new connection, click + New Connection.
- Select the API Connector connection.
- Enter
Spotify connectionfor the Name field. - Enter
Spotify API connectionfor the Description field. - Select
OAuthfrom the Auth Type list. - Enter
https://accounts.spotify.com/api/tokenfor the Access Token Path field. - Enter
https://accounts.spotify.com/authorize for the Authorize Path field. - Return to the app you created in Spotify. Click Settings. Copy and paste the Client ID and Client Secret values into the connection popup.
- Enter
playlist-read-privatein the Scope field. The API lists the scopes it requires.
The connection setup looks like this:

- Click Create.

- Sign in and agree to allow the app you created on Spotify to access your playlist information.
You created a connection to Spotify.
Call the Spotify API
- Create a flow.
- Add the API Connector – Get card.
- From the Connections list, select the
Spotify connection. - Enter
https://api.spotify.com/v1/me/playlistsfor the URL field. - Test the card or the flow.

Note: You need to have a playlist in your Spotify account.

Behind the scenes
When you create a connection to Spotify, Okta Workflows will request an access token for you and make an API call that looks like this:
curl --request GET \
--url https://api.spotify.com/v1/me/playlists \
--header 'Authorization: Bearer <access_token>'
Okta Workflows will also automatically request a new token when the current token expires.
Related Okta Workflows guides
- How to Call Watson Natural Language Understanding (NLU) API from Okta Workflows.
- How to Call an API When Itβs Not Available From an Existing Card (Connection).
Okta Workflows resources
π« Get help from Workflows specialists during weekly community office hours.
πΊ Learn from Workflows videos.
π Get help from support: discuss a Workflows topic or ask a question.
ππ»ββοΈ Get help from the community: join the #okta-workflows channel on MacAdmins Slack.
Leave a comment