简体   繁体   English

Facebook 登录:请确保您的 redirect_uri 与您在 OAuth 对话框中使用的相同

[英]Facebook login: Please make sure your redirect_uri is identical to the one you used in the OAuth dialog

So I'm out of ideas, I don't know what to check or debug anymore, but on the exception I get this:所以我没有想法,我不知道要检查或调试什么了,但在异常情况下我得到了这个:

string(188203) "Facebook\FacebookAuthorizationException Object
(
    [statusCode:Facebook\FacebookRequestException:private] => 400
    [rawResponse:Facebook\FacebookRequestException:private] => {"error":{"message":"Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request","type":"OAuthException","code":100,"fbtrace_id":"DqCCKoiN0r4"}}
    [responseData:Facebook\FacebookRequestException:private] => Array
        (
            [error] => Array
                (
                    [message] => Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
                    [type] => OAuthException
                    [code] => 100
                    [fbtrace_id] => DqCCKoiN0r4
                )

        )

    [message:protected] => Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
    [string:Exception:private] => 
    [code:protected] => 100

You can set redirect URI in Go to https://developers.facebook.com/apps Select your app.您可以在转到https://developers.facebook.com/apps 中设置重定向 URI 选择您的应用程序。

Under Products > Facebook Login > Settings在产品 > Facebook 登录 > 设置下

  • Enable Embedded Browser OAuth Login启用嵌入式浏览器 OAuth 登录
  • Set Valid OAuth Redirect URIs设置有效的 OAuth 重定向 URI

You can Validate Redirect URI with Redirect URI Validator.您可以使用重定向 URI 验证器验证重定向 URI。

You can only use https URIs.您只能使用 https URI。 Also set App Domain in Settings > Basic > App Domains还可以在设置 > 基本 > 应用程序域中设置应用程序域

Try / at the end of redirect URI在重定向 URI 的末尾尝试/

In my case I was using https://localhost everywhere but somehow when getting access token specifying https://localhost/ worked.在我的情况下,我在任何地方都使用https://localhost ,但在获取指定https://localhost/访问令牌时不知何故。

I believed you have used different redirect_uri in your facebook app settings and Oauth API code.我相信您在 facebook 应用程序设置和 Oauth API 代码中使用了不同的redirect_uri thats why you got this error.这就是您收到此错误的原因。

For facebook login you must set same redirect_uri into both place.对于 facebook 登录,您必须在两个地方设置相同的 redirect_uri。

As absurd as it sounds, verify you're using the correct app_secret.尽管听起来很荒谬,但请确认您使用的是正确的 app_secret。

Facebook will give you this instead of just saying "invalid secret" in the response Facebook 会给你这个,而不是仅仅在回复中说“无效的秘密”

这意味着您传递给 FB 的重定向 URI(通常在查询字符串中)与您在应用设置中设置的不匹配。

It can also be because of multiple slashes, for ex:也可能是因为多个斜杠,例如:

https://yoursite.com/auth/facebook/callback -> that's the one you added in the app settings
https://yoursite.com//auth/facebook/callback -> that's what you actually send

For me, it worked by replacing对我来说,它通过替换

callbackURL: "api/auth/facebook/redirect/",

to

callbackURL: "http://localhost:3000/api/auth/facebook/redirect/",

in the new FacebookStrategynew FacebookStrategy

Was stuck in the same problem for a long time .被同样的问题困了很久。 You will get this error when the redirect url is mismatching or does not exist or is wrongly formatted in the field (additional spaces or // ) , either the facebook app setting or while you are calling the API .当重定向 url 不匹配或不存在或字段中的格式错误(附加空格或 // )时,无论是 Facebook 应用程序设置还是调用 API 时,您都会收到此错误。
Solution解决方案
What worked for me was when ever you add a redirect URl you can check it in the valid redirect auth field uf it doesnot show valid when pressed check than that url is not the correct one对我有用的是,当您添加重定向 URl 时,您可以在有效的重定向身份验证字段中检查它 uf 它在按下检查时不显示有效,因为该 url 不是正确的

Make sure to have it exactly as in your FB settings.确保与您的 FB 设置完全相同。

For me, I had https://localhost:3000/ in my settings but https://localhost:3000 in my get access token call and this was the source of the error!对我来说,我的设置中有 https://localhost:3000/ 但在我的 get access token 调用中有 https://localhost:3000 ,这是错误的根源!

I had the same issue and non of the answers helped me, then I tried to make another Facebook app, and it solved my issue!我遇到了同样的问题,但没有一个答案对我有帮助,然后我尝试制作另一个 Facebook 应用程序,它解决了我的问题! I mean you have to use one application for Facebook OAuth and make another to use for Instagram oauth .我的意思是你必须为 Facebook OAuth使用一个应用程序,为 Instagram oauth使用另一个应用程序 seems Facebook has an issue with using both functionalities in one app. Facebook 在一个应用程序中使用这两种功能似乎存在问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM