问题
I have an asp.net web application where I am trying to upload tracks on Soundcloud using this method: Connecting to and uploading tracks with Soundcloud API using C# .NET
I created an app on soundcloud but I don't know how to generate my oauth token [oauth_token]
Thanks
回答1:
The oauth token is something you get per user after they authorize your app. For server-side web applications, you use the API credentials for your app to redirect the user to the SoundCloud authorization URL so they can login and approve your request.
When they approve your authorization request, they are sent to the redirect_uri
you specified when registering your app. There is a code in this response (code
in the querystring) that you will exchange for the oauth token you want (in this case its called access_token
). Then you need to save off that access_token
(associated with that user).
I recently created a SO post with C#
code detailing how to do this: How to let users login to my site using SoundCloud. You can also use this as an authentication method for your website (also what the post is about).
回答2:
You don't generate it on yourself, you get it from the SoundCloud API. You have first to authorize with your client_id, client_secret and a redirect_url then in the redirect_url (which the soundcloud server will call it should be some script on your server) you can get the token from the GET parameter "code". Then in the next step you can exchange the code for an access token.
Here is their example code in PHP:
<?php
// start.php
require_once 'Services/Soundcloud.php';
// create client object with app credentials
$client = new Services_Soundcloud('CLIENT_ID', 'CLIENT_SECRET', 'REDIRECT_URL');
<?php
// callback.php
// exchange authorization code for access token
$code = $_GET['code'];
$access_token = $client->accessToken($code);
来源:https://stackoverflow.com/questions/13153177/how-to-generate-soundcloud-oauth-token-access-token