[GH-ISSUE #228] "Insufficient client scope" on live site search #162

Closed
opened 2026-02-27 19:26:22 +03:00 by kerem · 2 comments
Owner

Originally created by @ghost on GitHub (Apr 25, 2021).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/228

EDIT: Sorry, title should be "Insufficient client scope" on live site using getMultipleAudioFeatures

Hi Jonathan,

I hope you're well.

I put my spotify app site on my live site today, and when I use getMultipleAudioFeatures I get this error:

  • Error number: 403
  • Error message: Insufficient client scope

I am passing trackIDs in an array:

$AudioFeaturesAlbumTracks = $api->getMultipleAudioFeatures($array_track_ids)

I am using these scopes:

$options = [
    'scope' => [
		'user-read-recently-played',
		'user-top-read',
		'playlist-modify-public',
		'user-follow-modify',
		'user-follow-read',
		'user-library-modify',
		'user-library-read'
    ],
	'show_dialog' => true
];

The strange thing is that the same scopes work when I've been testing my app on my localhost IIS server, but not on my live IIS server.

It's a strange one!

Thanks

Jim

Originally created by @ghost on GitHub (Apr 25, 2021). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/228 **EDIT: Sorry, title should be "Insufficient client scope" on live site using `getMultipleAudioFeatures`** Hi Jonathan, I hope you're well. I put my spotify app site on my live site today, and when I use `getMultipleAudioFeatures` I get this error: - Error number: 403 - Error message: Insufficient client scope I am passing trackIDs in an array: `$AudioFeaturesAlbumTracks = $api->getMultipleAudioFeatures($array_track_ids)` I am using these scopes: ``` $options = [ 'scope' => [ 'user-read-recently-played', 'user-top-read', 'playlist-modify-public', 'user-follow-modify', 'user-follow-read', 'user-library-modify', 'user-library-read' ], 'show_dialog' => true ]; ``` The strange thing is that the same scopes work when I've been testing my app on my localhost IIS server, but not on my live IIS server. It's a strange one! Thanks Jim
kerem closed this issue 2026-02-27 19:26:23 +03:00
Author
Owner

@ghost commented on GitHub (Apr 25, 2021):

I also tried with a much bigger list of scopes, but no luck:

$options = [
    'scope' => [
		'ugc-image-upload',
		'user-read-recently-played',
		'user-top-read',
		'user-read-playback-position',
		'user-read-playback-state',
		'user-modify-playback-state',
		'user-read-currently-playing',
		'app-remote-control',
		'streaming',
		'playlist-modify-public',
		'playlist-modify-private',
		'playlist-read-private',
		'playlist-read-collaborative',
		'user-follow-modify',
		'user-follow-read',
		'user-library-modify',
		'user-library-read',
		'user-read-email',
		'user-read-private'
    ],
	'show_dialog' => true
];

I call the API via:

$options = ['auto_refresh' => true, 'auto_retry' => true, 'return_assoc' => true];
$api = new SpotifyWebAPI\SpotifyWebAPI($options);	
$api->setAccessToken($accessToken);

I have also tested with:

$options = ['return_assoc' => true];
$api = new SpotifyWebAPI\SpotifyWebAPI($options);	
$api->setAccessToken($accessToken);

However, unfortunately changing those made no difference.

I call getMultipleAudioFeatures like this:

try {
	$AudioFeaturesAlbumTracks = $api->getMultipleAudioFeatures($array_track_ids);
} catch (SpotifyWebAPI\SpotifyWebAPIException $e) {
	print_r($e);
}

The code errors before getting to the catch part - it is erroring / returning the message about invalid scopes on this line:

$AudioFeaturesAlbumTracks = $api->getMultipleAudioFeatures($array_track_ids);

I can't see anything in the docs for the method referring to the correct scope to use.

Do you know if I can do any additional debugging to get to the bottom of what might be happening?

Thanks

Jim

<!-- gh-comment-id:826391952 --> @ghost commented on GitHub (Apr 25, 2021): I also tried with a much bigger list of scopes, but no luck: ``` $options = [ 'scope' => [ 'ugc-image-upload', 'user-read-recently-played', 'user-top-read', 'user-read-playback-position', 'user-read-playback-state', 'user-modify-playback-state', 'user-read-currently-playing', 'app-remote-control', 'streaming', 'playlist-modify-public', 'playlist-modify-private', 'playlist-read-private', 'playlist-read-collaborative', 'user-follow-modify', 'user-follow-read', 'user-library-modify', 'user-library-read', 'user-read-email', 'user-read-private' ], 'show_dialog' => true ]; ``` I call the API via: ``` $options = ['auto_refresh' => true, 'auto_retry' => true, 'return_assoc' => true]; $api = new SpotifyWebAPI\SpotifyWebAPI($options); $api->setAccessToken($accessToken); ``` I have also tested with: ``` $options = ['return_assoc' => true]; $api = new SpotifyWebAPI\SpotifyWebAPI($options); $api->setAccessToken($accessToken); ``` However, unfortunately changing those made no difference. I call `getMultipleAudioFeatures` like this: ``` try { $AudioFeaturesAlbumTracks = $api->getMultipleAudioFeatures($array_track_ids); } catch (SpotifyWebAPI\SpotifyWebAPIException $e) { print_r($e); } ``` The code errors before getting to the catch part - it is erroring / returning the message about invalid scopes on this line: `$AudioFeaturesAlbumTracks = $api->getMultipleAudioFeatures($array_track_ids);` I can't see anything [in the docs](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-several-audio-features) for the method referring to the correct scope to use. Do you know if I can do any additional debugging to get to the bottom of what might be happening? Thanks Jim
Author
Owner

@ghost commented on GitHub (Apr 26, 2021):

Hi Jonathan - I realised I wasn't using the most up to date version of your code.

Re. debugging - I should just have checked the PHP errors log which had all the info I needed:

[25-Apr-2021 22:40:54 Europe/London] PHP Fatal error: Uncaught Error: Call to undefined method SpotifyWebAPI\SpotifyWebAPI::getMultipleAudioFeatures() in C:\inetpub\wwwroot\site\info-track.php:192

I had the most up to date code on localhost but not on the live site, so once the live site was up to date, problem solved.

Simple in the end!

Thanks

Jim

<!-- gh-comment-id:826562069 --> @ghost commented on GitHub (Apr 26, 2021): Hi Jonathan - I realised I wasn't using the most up to date version of your code. Re. debugging - I should just have checked the PHP errors log which had all the info I needed: `[25-Apr-2021 22:40:54 Europe/London] PHP Fatal error: Uncaught Error: Call to undefined method SpotifyWebAPI\SpotifyWebAPI::getMultipleAudioFeatures() in C:\inetpub\wwwroot\site\info-track.php:192` I had the most up to date code on localhost but not on the live site, so once the live site was up to date, problem solved. Simple in the end! Thanks Jim
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#162
No description provided.