Plan
Premium
Country
US
Device
Desktop PC
Operating System
Windows 11
PREFIX: My account was started yesterday & set to the single-user monthly premium account.
My Question or Issue
I have a Godot desktop application that I added Spotify to. I've been able to successfully execute various Spotify REST APIs, such as Getting Available Devices & Searching for an Item, returning either 200, 202, or 204 success codes using Godot's HTTP Request class. However, I keep failing POST calls to APIs that require the 'user-modify-playback-state' authorization scope, e.g., Add Item to Playback Queue. Do note that I already have other entire HTTP API suites (e.g., Twitch APIs) implemented & working currently using GETs, POSTs, PUTs, & DELETEs in this application.
I have granted access, shown in the first attached image, to the application with Spotify's application authorization redirect page & confirmed it is listed under my Spotify account, e.g.,
OS.ShellOpen(
uri: $"https://accounts.spotify.com/authorize?" +
$"client_id={m_spotifyData.ClientId}&" +
$"response_type=code&" +
$"redirect_uri=http://localhost:8888/callback&" +
$"scope={Uri.EscapeDataString(authorizationScopes)}"
);
Current Authorization Scopes:
- user-modify-playback-state
- user-read-currently-playing
- user-read-playback-state
- user-read-private
This has resulted in an authorization code that I was able to use for retrieving an access token, the request being provided in the second attached screenshot, that verified the authorization scopes I used, via., the Request an Access Token response. All requested authorization scopes were included in the "scope" response body in the spaced format, e.g.,
"user-modify-playback-state user-read-currently-playing user-read-playback-state user-read-private"
With respect to Add Item to Playback Queue, & subsequent APIs that require the user-modify-playback-state, this is resulting in an error code from Godot's HTTP Request class that signals I do not have write access since adding an item to the playback queue is a POST request. If I change the Add Item to Playback Queue request to a GET request, it will succeed with a 200-success code as if I attempted to use Get the User's Queue, as they share the same base endpoint (https://api.spotify.com/v1/me/player/queue). I presume the Uri that is required for the Add Item to Playback Queue endpoint is discarded when making the GET request. Using the correct POST HTTP request, the resulting headers & body for the call to Add Item to Playback Queue are empty with an HTTP response code of 0, not even a 4XX error code. I am uncertain why I am getting a write access error when my access token was approved for user-modify-playback-state.
The third screenshot attached is the HTTP request being sent out to Add Item to Playback Queue API after a search item has been successfully retrieved from the Searching for an Item API, where item[0].Uri is a valid track Uri provided from Spotify. I tested a Uri retrieved through Searching for an Item API on the documentation page of Add Item to Playback Queue API, which successfully added the track to my Spotify queue. The subsequent Add Item to Playback Queue API fails with the Godot error & a response code of 0.
Is there any inclination of what I may be doing incorrectly?
The biggest flag here is that I already have 40+ Twitch HTTP APIs working correctly with POSTs, GETs, & DELETEs. I do not think this is an error within Godot or my application's HTTP set up. My biggest inclination is thinking that my account is not approved for user-modify-playback-state authorization or that it's because my Spotify account was started yesterday with premium. I do know the Add Item to Playback Queue API I am trying to access requires an account to have premium.
Things I've verified:
- Ensured Add Item to Playback Queue API endpoint Uri is correct.
- Ensured authorization scopes included user-modify-playback-state.
- Removed authorization of the application, requested a new authorization code, re-authorized the application for account access, & requested a new access token with the new authorization code.
- Successfully tested other endpoints that did not require user-modify-playback-state authorization scope & received 2XX success codes.
- Verified ability to queue up a song correctly with a retrieved search item Uri through the test API on the Add Item to Playback Queue API documentation page.
- Verified application was approved for access on my Spotify account, e.g., Manage Apps.