[GH-ISSUE #141] Error: Get Followed Artists #86

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

Originally created by @C0d3Br3aker on GitHub (Sep 25, 2018).
Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/141

If I want to get all artists following by one user it prints the following error:

<b>Fatal error</b>:  Uncaught SpotifyWebAPI\SpotifyWebAPIException: Insufficient client scope in jwilsson\spotify-web-api-php\src\Request.php:39
Stack trace:
#0 jwilsson\spotify-web-api-php\src\Request.php(235): SpotifyWebAPI\Request-&gt;parseBody(Object(stdClass), 403)
#1 jwilsson\spotify-web-api-php\src\Request.php(114): SpotifyWebAPI\Request-&gt;send('GET', 'https://api.spo...', 'type=artist', Array)
#2 jwilsson\spotify-web-api-php\src\SpotifyWebAPI.php(1258): SpotifyWebAPI\Request-&gt;api('GET', '/v1/me/followin...', Array, Array)
#3 C:\xampp\htdocs\spot\index.php(35): SpotifyWebAPI\SpotifyWebAPI-&gt;getUserFollowedArtists()
#4 {main}
thrown in <b>jwilsson\spotify-web-api-php\src\Request.php</b> on line <b>39</b>

My Code:

<?php

require 'vendor/autoload.php';

define("CLIENT_ID", "XXXXX");
define("CLIENT_SECRET", "XXXXX");
define("REDIRECT_URI", "XXXXX");

$session = new SpotifyWebAPI\Session(
    CLIENT_ID,
    CLIENT_SECRET,
    REDIRECT_URI
);
$api = new SpotifyWebAPI\SpotifyWebAPI();
if (isset($_GET['code'])) {
    $session->requestAccessToken($_GET['code']);
    $api->setAccessToken($session->getAccessToken());
} else {
    $options = [
        'scope' => [
            'user-read-email',
        ],
    ];
    header('Location: ' . $session->getAuthorizeUrl($options));
    die();
}
$artist = $api->getUserFollowedArtists();
Originally created by @C0d3Br3aker on GitHub (Sep 25, 2018). Original GitHub issue: https://github.com/jwilsson/spotify-web-api-php/issues/141 If I want to get all artists following by one user it prints the following error: ``` <b>Fatal error</b>: Uncaught SpotifyWebAPI\SpotifyWebAPIException: Insufficient client scope in jwilsson\spotify-web-api-php\src\Request.php:39 Stack trace: #0 jwilsson\spotify-web-api-php\src\Request.php(235): SpotifyWebAPI\Request-&gt;parseBody(Object(stdClass), 403) #1 jwilsson\spotify-web-api-php\src\Request.php(114): SpotifyWebAPI\Request-&gt;send('GET', 'https://api.spo...', 'type=artist', Array) #2 jwilsson\spotify-web-api-php\src\SpotifyWebAPI.php(1258): SpotifyWebAPI\Request-&gt;api('GET', '/v1/me/followin...', Array, Array) #3 C:\xampp\htdocs\spot\index.php(35): SpotifyWebAPI\SpotifyWebAPI-&gt;getUserFollowedArtists() #4 {main} thrown in <b>jwilsson\spotify-web-api-php\src\Request.php</b> on line <b>39</b> ``` My Code: ``` <?php require 'vendor/autoload.php'; define("CLIENT_ID", "XXXXX"); define("CLIENT_SECRET", "XXXXX"); define("REDIRECT_URI", "XXXXX"); $session = new SpotifyWebAPI\Session( CLIENT_ID, CLIENT_SECRET, REDIRECT_URI ); $api = new SpotifyWebAPI\SpotifyWebAPI(); if (isset($_GET['code'])) { $session->requestAccessToken($_GET['code']); $api->setAccessToken($session->getAccessToken()); } else { $options = [ 'scope' => [ 'user-read-email', ], ]; header('Location: ' . $session->getAuthorizeUrl($options)); die(); } $artist = $api->getUserFollowedArtists(); ```
kerem closed this issue 2026-02-27 19:25:58 +03:00
Author
Owner

@C0d3Br3aker commented on GitHub (Sep 25, 2018):

solution found. option 'user-follow-read' wasn't set.

<!-- gh-comment-id:424534178 --> @C0d3Br3aker commented on GitHub (Sep 25, 2018): solution found. option 'user-follow-read' wasn't set.
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#86
No description provided.