oAuth Instagramlogin

我试图从Instagram使用oAuth 2获取访问令牌,以在范围中使用它。 我不明白我应该如何configuration“redirect_uri”(尝试了很多组合),如果我在本地应用程序中使用它,这意味着我不需要任何网站redirect,我需要redirect到应用程序本身,login后(也许我解释不正确的东西,因为不明白如何redirect_uri在本地应用程序工作)

AppDelegate.swift补充说:

func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool { if (url.host == "oauth-callback") { OAuthSwift.handleOpenURL(url) } return true } 

ViewController.swift中

 import UIKit import OAuthSwift class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let oauthswift = OAuth2Swift( consumerKey: "cc6dd7ca50c74f4f92a1a8328c9d4426", consumerSecret: "74f6bf3c839b4e15a747a332d#######", authorizeUrl: "https://api.instagram.com/oauth/authorize", responseType: "token" ) oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/instagram")!, scope: "likes+comments", state:"INSTAGRAM", success: { credential, response, parameters in print(credential.oauth_token) }, failure: { error in print(error.localizedDescription) } ) } } 

(由于声誉,无法添加没有url的图片):

项目信息中的Urlscheme

Instagram设置

题:

  • 我做错了什么?

  • 如何解决它,所以应用程序可以“打印(credential.oauth_token)”发生。

固定:

 NSURL(string: "oauth-swift://oauth-callback/instagram")!, 

应该改成

 NSURL(string: "AppName://oauth-callback")!, 

而且在Instagram的设置