Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Authorization code flow on backend/server

Solved!

Authorization code flow on backend/server

I'm working on a project using the Spotify API that I'm migrating from my local machine over to an Azure Function. It uses the Authorization Code Flow for access to the Spotify data of whomever logs in on my program. The issue is, of course, that the 'Grant permissions' page opens up on the server and not the end-users local machine. Is there any way to either allow access from the server or send back the 'Grant permissions' request to the user's machine so that they can give access to my program? 

I've looked into other authentication flows, but all of them either require this type of user input or don't allow changing user information (e.g. modifying a playlist) which my program needs access to.

Reply

Accepted Solutions
Marked as solution

You can set up the authorization code flow on your computer, with the redirect url pointing to your server. After you log in, a code you'll need for the flow will be in the URL bar.

After you have completed the flow, you can store access token and refresh token on your server to let your app use them. You will need to implement the mechanisms to request a refreshed access token on your server for when it expires after one hour.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

View solution in original post

1 Reply
Marked as solution

You can set up the authorization code flow on your computer, with the redirect url pointing to your server. After you log in, a code you'll need for the flow will be in the URL bar.

After you have completed the flow, you can store access token and refresh token on your server to let your app use them. You will need to implement the mechanisms to request a refreshed access token on your server for when it expires after one hour.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Suggested posts

Type a product name