Soundcloud API 401

…衆ロ難τιáo~ 提交于 2020-04-16 04:57:13

问题


So I'm trying to get a playlist with SoundCloud API, but I'm getting a 401 when setting an access token.

<?PHP
    require_once('Services/Soundcloud.php');

   $client = new Services_Soundcloud('id', 'secret', 'uri');
    if (!isset($_GET['code']))
    {
        header("Location: " . $client->getAuthorizeUrl());
    }
    $access_token = $client->accessToken($_GET['code']);
    $client->setAccessToken($access_token);
?>

I think it may be a problem with me reusing the access token (maybe?). I'm not sure.


回答1:


For some reason it's broken again. I receive codes ending with hash (#) which gets stripped when I try to get them with $_GET['code']. Even when I manually append the hash the authentication still ends with 401, so I assume this is an internal error.




回答2:


Resolved it by simply adding posting "scope" with "non-expiring" and then using that code.

header("Location: " . $client->getAuthorizeUrl(array('scope' => 'non-expiring'));


来源:https://stackoverflow.com/questions/23031661/soundcloud-api-401

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!