[GH-ISSUE #171] Authorization Scopes Without Redirects? #110

Closed
opened 2026-02-27 19:26:07 +03:00 by kerem · 1 comment
Owner

Originally created by @m00bs on GitHub (Nov 11, 2019).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/171

Is it possible to set an authorization scope without redirects? I'm trying to put a script together that will automate adding tracks to my own personal playlists using your "addPlaylistTracks" function. However, I'm having difficulty adding the scope "playlist-modify-public" and retrieving the updated token as you've described in the docs. Ideally I'm trying to initiate the session with the proper authorization without any redirects.

I'm basically trying to automate the curation process for my list so I have a fresh daily playlist without having to click or approve anything.

My PHP is a bit rusty so any guidance you can provide would be appreciated.

Originally created by @m00bs on GitHub (Nov 11, 2019). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/171 Is it possible to set an authorization scope without redirects? I'm trying to put a script together that will automate adding tracks to my own personal playlists using your "addPlaylistTracks" function. However, I'm having difficulty adding the scope "playlist-modify-public" and retrieving the updated token as you've described in the docs. Ideally I'm trying to initiate the session with the proper authorization without any redirects. I'm basically trying to automate the curation process for my list so I have a fresh daily playlist without having to click or approve anything. My PHP is a bit rusty so any guidance you can provide would be appreciated.
kerem 2026-02-27 19:26:07 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jwilsson commented on GitHub (Nov 11, 2019):

Hi!
Since you want to access user data you need to perform a redirect at least once. It should be possible to perform the initial redirect flow and then just use the refresh token in your automation script.

For example, something like this should work.

  1. One time only, follow the steps in Authorization Code Flow. You can probably get away with just printing the refresh token and store it somewhere accessible from your automation script.
  2. In your automation script, setup the API wrapper to automatically refresh access tokens.
  3. Call the addPlaylistTracks method and update the playlists.
  4. After each call to addPlaylistTracks, save the new access and refresh tokens from step 2.
<!-- gh-comment-id:552409887 --> @jwilsson commented on GitHub (Nov 11, 2019): Hi! Since you want to access user data you need to perform a redirect at least once. It should be possible to perform the initial redirect flow and then just use the refresh token in your automation script. For example, something like this should work. 1. One time only, follow the steps in [Authorization Code Flow](https://github.com/jwilsson/spotify-web-api-php/blob/975994110a919d06e9bc51dbe095e66d178cc644/docs/examples/access-token-with-authorization-code-flow.md). You can probably get away with just printing the refresh token and store it somewhere accessible from your automation script. 2. In your automation script, setup the API wrapper to [automatically refresh access tokens](https://github.com/jwilsson/spotify-web-api-php/blob/c9b9e0501ca8925b87e671d7dc479ec6e5fb21e7/docs/examples/automatically-refreshing-access-tokens.md). 3. Call the `addPlaylistTracks` method and update the playlists. 4. After each call to `addPlaylistTracks`, save the new access and refresh tokens from step 2.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-web-api-php#110
No description provided.