尝试为我的应用程序设置身份验证,一切似乎都正常工作,但是当我尝试对其进行测试时,我收到了这条错误消息
Authorization Error Error 400: redirect_uri_mismatch The redirect URI in the request, http://localhost:3000/api/auth/callback/google, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/${your_client_id}?project=${your_project_number}
你能指出正确的方向来解决这个问题吗?
最佳答案
Error 400: redirect_uri_mismatch
是配置问题。重定向 uri 用于在用户同意您的应用程序访问您的数据后将授权代码返回给您的应用程序。您已在 Google 开发者控制台上创建了网络客户端凭据。
你需要做的是回到那里并添加一个 Redirect uri
http://localhost:3000/api/auth/callback/google
它必须完全匹配,不要在末尾添加任何空格或任何东西。
如果您有任何问题,我有一个视频会向您展示如何添加它 Google OAuth2: How the fix redirect_uri_mismatch error. Part 2 server sided web applications.
关于oauth - 从 Google 获取登录和重定向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67096519/