我有我的传出和传入 URI
self.outgoingRedirect = @"https://courseera.com";
self.incomingRedirect = @"https://myscheme.com";
其余代码如下所示-
[[NXOAuth2AccountStore sharedStore]
setClientID:@"xxx"
secret:@"xxx"
authorizationURL:[NSURL
URLWithString:@"https://api.instagram.com/oauth/authorize"]
tokenURL:[NSURL
URLWithString:@"https://api.instagram.com/oauth/access_token"]
redirectURL:[NSURL URLWithString:self.outgoingRedirect]
forAccountType:@"Instagram"];
返回是; }
(BOOL) application:(UIApplication )app openURL:(NSURL *)url options:
(NSDictionary *)options{
if([self.incomingRedirect containsString:[url scheme] ] &&
[self.incomingRedirect containsString:[url host]]){
NSURL *constructed = [NSURL URLWithString:[NSString
stringWithFormat:@"%@?%@",self.outgoingRedirect,[url query]]];
NSLog(@"We received a callback URL");
return [[NXOAuth2AccountStore sharedStore]
handleRedirectURL:constructed];
}
else{
return [[NXOAuth2AccountStore sharedStore] handleRedirectURL:url];
}
};
我收到错误,因为"重定向 URI 与注册的重定向 URI 不匹配"。
问题是Instagram只是将您重定向到myscheme.com
。相反,您需要做的是将redirectURI
设置为https://myscheme.com/instagram.html?igCLIENTID://authorize
,并在项目中设置redirect uri
以便instagram
igCLIENTID://authorize
,并在 myScheme 网站上点击instagram.html
网页时尝试重定向到igCLIENTID://authorize
iOS 将识别这一点,并知道您的应用程序将处理此问题并启动您的应用程序。Instagram 以前才开始这样做,你可以没有https
redirect uri
但情况不再如此。