IOS 应用程序中 instagram 集成中的“重定向 URI 与注册的重定向 URI 不匹配”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16188786/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Redirect URI doesnot match registered redirect URI" in instagram integration in IOS app
提问by iSwaroop
I am working on iPad app, and I need to integrate Instagram. I found a sample that works fine. But coming to my app I registered as new user in instagram developer account. Though I am following the steps as said in Instagram API docs, I am getting an error "Redirect URI doesnot match registered redirect URI".
我正在开发 iPad 应用程序,我需要集成 Instagram。我找到了一个工作正常的样本。但是来到我的应用程序时,我在 Instagram 开发者帐户中注册为新用户。虽然我按照 Instagram API 文档中所述的步骤操作,但我收到错误“重定向 URI 与注册的重定向 URI 不匹配”。
Can someone guide me on how to generate Redirect URI?
有人可以指导我如何生成重定向 URI?
Here is what I did in Instagram.
这是我在 Instagram 上所做的。
And in my simulator I am getting this error :
在我的模拟器中,我收到此错误:
回答by Sujal
Use REDIRECT URI : igeb6240d263fb4736b3740af87edd18ea://authorize
for your Application
使用重定向 URI :igeb6240d263fb4736b3740af87edd18ea://authorize
为您的应用程序
your REDIRECT URI should be : "ig" + "your clientId" + "://authorize"
你的重定向 URI 应该是:“ig”+“你的 clientId”+“://authorize”
回答by Tim Bodeit
You can use whatever you want as your redirect URI. You have to pass the redirect URI as a Get-parameter in your authorize request.
您可以使用任何您想要的作为重定向 URI。您必须在授权请求中将重定向 URI 作为 Get 参数传递。
Make sure both of them match! You can navigate to subfolders or add additional parameters to it, but the beginning of it has to stay the same.
确保两者匹配!您可以导航到子文件夹或向其中添加其他参数,但它的开头必须保持不变。
I would suggest not to use your website, but to link to one of your apps url schemes. For a guide on how to set those up, look here: http://www.idev101.com/code/Objective-C/custom_url_schemes.html
我建议不要使用您的网站,而是链接到您的应用程序 url 方案之一。有关如何设置这些的指南,请查看此处:http: //www.idev101.com/code/Objective-C/custom_url_schemes.html
So for example you could use myapp://
as your default redirect URI, that you want to register with instagram.
因此,例如,您可以将其myapp://
用作默认重定向 URI,您希望在 Instagram 注册。
Inside your app you can add additional parameters to it. Instagram will pass those on to your redirect URI, so you can read them out again in your AppDelegate or on your Server. Make sure you encode the redirect URI properly. The easiest way to do this would be:
在您的应用程序中,您可以向其添加其他参数。Instagram 会将它们传递给您的重定向 URI,因此您可以在 AppDelegate 或服务器上再次读取它们。确保正确编码重定向 URI。最简单的方法是:
NSString *unescaped = [NSString stringWithFormat:@"myapp://?someparameter=%@",theparametersvalue];
NSString *redirectURI = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(
NULL,
(__bridge CFStringRef) unescaped,
NULL,
CFSTR("!*'();:@&=+$,/?%#[]"),
kCFStringEncodingUTF8));
Now insert redirectURI
together with your client id into this URL and fire off the request:
现在将redirectURI
您的客户端 ID 一起插入此 URL 并触发请求:
https://api.instagram.com/oauth/authorize/?client_id=YOURCLIENTID&redirect_uri=YOURREDIRECTURI&response_type=code
If you need more than the basic permissions, check out scopes in the documentation.
如果您需要的不仅仅是基本权限,请查看文档中的范围。