问题
We have an existing application on SoundCloud that was created some time ago and set up to use OAuth1. Recently we needed to expand SoundCloud-related functionality and, because of some problems with the old library, had to upgrade to new cocoa-api-wrapper library that uses OAuth2 client.
The problem now is that we cannot access our application with its key/secret because of the different version of OAuth. While it is possible to set up new application and get new key/secret pair, we wouldn't want to lose all the data associated with the current application.
Is there a way to have the same SoundCloud application accessible with both versions of OAuth (OAuth1 is still being used)? If not, what's the best way to handle this situation?
回答1:
Yes. You can migrate an OAuth1 token to an OAuth2 token by sending a POST request to the following endpoint:
https://api.soundcloud.com/oauth2/token
with the following parameters:
- client_id='YOUR_CLIENT_ID'
- client_secret='YOUR_CLIENT_SECRET'
- grant_type='oauth1_token'
- refresh_token='OAUTH1_TOKEN'
The response will contain an OAuth2 token (as well as expires_in
, scope
, refresh_token
).
来源:https://stackoverflow.com/questions/15303023/migrating-from-oauth1-to-oauth2