首页 > 在cocoa 开发中,对于Instagram OAuth2 如何在没有服务端的情况下完成授权?

在cocoa 开发中,对于Instagram OAuth2 如何在没有服务端的情况下完成授权?

本来我是想通过Web授权,然后回调应用的专有地址,比如在instagram dev设置中设置回调地址为 myapp://xxxx 这样,它授权完成后会把token接在转发连接上,并且会发送到我的应用程序中,但是现在发现instagram的回调地址只能是http开头的。这样我在没有自己的服务端的情况下,就无非获取instagram的回调了。
请问这一块授权有什么其他的解决方法吗?谢谢!


第一步:用webview打开

https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code

委托里判断每次载入URL,如果URL以REDIRECT-URL开头,则验证完成(第二步),不知道你是不是卡在了这里

http://your-redirect-uri?code=CODE

拿到CODE,POST给insta(第三步)post参数如下

client_id: your client id
client_secret: your client secret
grant_type: authorization_code is currently the only supported value
redirect_uri: the redirect_uri you used in the authorization request. Note: this has to be the same value as in the authorization request.
code: the exact code you received during the authorization step.
【热门文章】
【热门文章】