SpotifyWebAPI\Session::requestCredentialsToken PHP Method

requestCredentialsToken() public method

Request an access token using the Client Credentials Flow.
public requestCredentialsToken ( array $scope = [] ) : boolean
$scope array Optional. Scope(s) to request from the user.
return boolean True when an access token was successfully granted, false otherwise.
    public function requestCredentialsToken($scope = [])
    {
        $payload = base64_encode($this->getClientId() . ':' . $this->getClientSecret());
        $parameters = ['grant_type' => 'client_credentials', 'scope' => implode(' ', $scope)];
        $headers = ['Authorization' => 'Basic ' . $payload];
        $response = $this->request->account('POST', '/api/token', $parameters, $headers);
        $response = $response['body'];
        if (isset($response->access_token)) {
            $this->accessToken = $response->access_token;
            $this->expirationTime = time() + $response->expires_in;
            return true;
        }
        return false;
    }