Is there a way to get the redirect url after a https / api request?
7 ビュー (過去 30 日間)
古いコメントを表示
I'm using the Spotify API and in order to get authorization I need to get the url of the redirected page after completing the first api request.
client_id = "CLIENT_CODE"; % Specific Application client id
redirect_uri = 'REDIRECT_URL';
scope = 'user-read-private user-read-email';
response_type = 'code';
% Authorization url
auth_url = "https://accounts.spotify.com/authorize?";
auth_url = strcat(auth_url, "client_id="+client_id);
auth_url = strcat(auth_url, "&redirect_uri="+redirect_uri);
auth_url = strcat(auth_url, "&response_type="+response_type);
web(auth_url)
Right now, when you input my actual client code and redirect_url, it opens up the authorization page and then after you authorize (or don't) the page is redirect to a url like this:
REDIRECT_URL/?code=AQDkK3AcQqCnoiV37f1Ied1DjOyEINjnzKB1HA-JO7c0HIyYL2VR0PGrbawMQiKkuquXUl7UlI19VaEvDp2jzxsOF_scEItkktas0voMUgc4p2q1W8i0Kx4a_i3KB0dB6AtRO_ruQWXCVto_9ZQLn_bqJ7soiGsYN_3rLO6nheky5_VREMdzi9IVlzQg0A
This information after the 'code=' is the authorization key that I need.
Does anyone know how to retrieve this in MATLAB?
0 件のコメント
採用された回答
Mohammad Sami
2022 年 4 月 7 日
You can use the matlab.net.http interface to follow the redirects.
request = matlab.net.http.RequestMessage;
uri = matlab.net.URI('https://goo.gl/maps/co8U2mMv8zFweDzN8');
[response,completedrequest,history] = send(request,uri);
finaluri = history(end).URI;
disp(finaluri);
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!