Sync Spotify access token every 5 minutes
Recipe ToolsMarketingDeveloper ToolAPI Integration
What it does
When the clock triggers every 5 minutes, this automation retrieves a fresh access token from Spotify. It stores the token for use in other automations, and stops with an error if the request fails.
Who it's for
Engineering teams who need a current Spotify access token available without manual refresh.
How teams use this
Keep Spotify API calls authenticated
Refresh the access token every 5 minutes so automations that sync Spotify data always have a valid token. The team does not need to manually refresh or manage token expiry.
Prevent failed API requests downstream
Stop the job if the REST request fails so the team knows the token refresh broke and can investigate. No stale token gets stored in the system.
Alert the team on token failure
Add a Slack step that notifies the engineering channel when the token request fails. The team gets immediate visibility instead of discovering the issue later in the day.
Monitor token refresh for compliance
Set up logging to track each token refresh so the security team can audit when tokens were rotated. This creates a record for compliance and troubleshooting.
How it works
- Start the token refresh cycle. The clock starts this automation on a 5-minute schedule so the access token stays fresh for API calls.
- Retrieve token from Spotify via REST. Make an HTTP request to Spotify to retrieve a new access token. The Rest connector sends the request and captures the response for storage.
- Store the token for other automations. Call Upsert Spotify access token to save the new token so other automations can use it without requesting a fresh one.
- Stop the job on error. If the HTTP request to Spotify fails, stop this automation so the team knows the token refresh broke and can investigate the issue.