xcode 如何解决IOS中的身份验证错误“重定向URI与注册的重定向URI不匹配”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24649152/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:11:26  来源:igfitidea点击:

How to solve auth Error "Redirect URI does not match registered redirect URI" in IOS?

iosobjective-cxcodeinstagram

提问by BenAY

I am working register a new client from instagram developer page for my iphone app.But I have problem.I created client id but it given this error :

我正在为我的 iphone 应用程序从 instagram 开发人员页面注册一个新客户端。但我有问题。我创建了客户端 ID,但它给出了这个错误:

{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI does not match registered redirect URI"}

{"code": 400, "error_type": "OAuthException", "error_message": "重定向 URI 与注册的重定向 URI 不匹配"}

Actually,I used for connection this link in ios code:

实际上,我在 ios 代码中用于连接此链接:

https://instagram.com/oauth/authorize?response_type=token&redirect_uri=igd9fe475655e646cd8025bed7f8626230%3A%2F%2Fauthorize&scope=comments+likes&client_id=d9fe475655e646cd8025bed7f8626230

https://instagram.com/oauth/authorize?response_type=token&redirect_uri=igd9fe475655e646cd8025bed7f8626230%3A%2F%2Fauthorize&scope=comments+likes&client_id=d9fe475655e646cdf8022

So,I found sample Client ID.When I've tried to sample Client ID on this link:

所以,我找到了示例客户端 ID。当我尝试在此链接上采样客户端 ID 时:

https://instagram.com/oauth/authorize/?response_type=token&redirect_uri=igfd725621c5e44198a5b8ad3f7a0ffa09%3A%2F%2Fauthorize&scope=comments+likes&client_id=fd725621c5e44198a5b8ad3f7a0ffa09

https://instagram.com/oauth/authorize/?response_type=token&redirect_uri=igfd725621c5e44198a5b8ad3f7a0ffa09%3A%2F%2Fauthorize&scope=comments+likes&client_id=fd725621c8a5a40aff

it's working good on same code.

它在相同的代码上运行良好。

But when ? created Client ID.It is not working.I checked a link.But,I didn't solve this error.

但当 ?创建了客户端 ID。它不起作用。我检查 了一个链接。但是,我没有解决这个错误。

Can someone guide me on how to generate Redirect a new client? or What is the my problem ?

有人可以指导我如何生成重定向新客户端吗?或者我的问题是什么?

回答by Ritu

enter image description hereWhile registering your app with Instagram(to generate client_id). You have to set the redirect_uri there.

在此处输入图片说明在 Instagram 注册您的应用程序时(生成 client_id)。您必须在那里设置 redirect_uri。

Please check the image and configure as I did.

请检查图像并像我一样配置。

回答by CIRCLE

For anyone that is having this issue and the redirect uri provided to instagram is exactly the same as the one you're using, i've found that some users were typing my website address as http://www.example.com/loginwhen in my instagram api it was http://example.com/login.

对于遇到此问题并且提供给 instagram 的重定向 uri 与您使用的完全相同的任何人,我发现有些用户正在输入我的网站地址,就像http://www.example.com/login在我的 instagram api 中一样http://example.com/login

Then I created a php script to detect if the string wwwexists in my url and then reload to the same page but without the www.

然后我创建了一个 php 脚本来检测字符串是否www存在于我的 url 中,然后重新加载到同一页面但没有www.

if(strpos($_SERVER['HTTP_HOST'], 'www.') !== FALSE) {
    header("Location: ".str_replace('www.', '', $_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI']));
}