我正在将本教程中的auth0集成到我自己的应用程序中,并且在auth0日志中反映的身份验证中遇到了一些问题。
这发生在按下我的react登录按钮时:
Login.js
import React from "react";
import { useAuth0 } from "@auth0/auth0-react";
import '../components/App.css'
const LoginButton = () => {
const { loginWithRedirect } = useAuth0();
return <button class="btn btn-primary" onClick={() => loginWithRedirect()}>Log In</button>;
};
export default LoginButton;
但是,在Auth0应用程序日志中,我看到我已经成功地通过了身份验证,并且我还得到了一个Failed Exchange
、Successful Login
和Warning During Login
。
固定日志:Warning During Login
以下是Warning During Login
日志的文本
您使用的是仅用于开发和测试的Auth0开发密钥。此连接(GoogleOAuth2)应配置为您自己的开发密钥,以使“同意”页面能够显示您的徽标,而不是Auth0的,并启用此连接的SSO。不建议在生产环境中使用AUTH0开发密钥。要了解更多关于开发密钥的信息,请参考https://auth0.com/docs/connections/social/devkeys。
这是通过在这些指示网站上跟踪Auth0来修正的。实质上:
破碎:Login Successful
日志显示它成功登录。但是,在我的应用程序中,我单击Login按钮,并没有出现预期的auth0模式。
{
"date": "2020-10-14T09:14:06.549Z",
"type": "s",
"connection_id": "",
"client_id": "<MyClientId>",
"client_name": "<MyClientName>",
"ip": "<MyIP>",
"user_agent": "Safari 13.1.2 / Mac OS X 10.15.6",
"details": {
"prompts": [],
"completedAt": 1602666846548,
"elapsedTime": null,
"session_id": "m0AeJer-FhZ0rb9UFPWgvDkvN7MW36h_"
},
"hostname": "<MyHost>",
"user_id": "<MyUserID>",
"user_name": "<MyUserName>",
"auth0_client": {
"name": "auth0-react",
"version": "1.1.0"
},
"log_id": "90020201014091409270008789595401783120816526823843168290",
"_id": "90020201014091409270008789595401783120816526823843168290",
"isMobile": false,
"description": "Successful login"
}
查看safari中的响应头,令牌请求有401
d。
URL: https://<testdomain>.auth0.com/oauth/token
Status: 401
Source: Network
Address: <testaddress>
Initiator:
auth0-spa-js.production.esm.js:15
固定日志:Failed Exchange
在确保我正确地连接到goole之后,我发现这个问题仍然存在。查看日志,我得到了Failed Exchange
标题下的如下内容。
{
"date": "2020-10-14T09:14:07.304Z",
"type": "feacft",
"description": "Unauthorized",
"connection_id": "",
"client_id": "<MyClientId>",
"client_name": null,
"ip": "<TheIP>",
"user_agent": "Safari 13.1.2 / Mac OS X 10.15.6",
"details": {
"code": "*************Rw7"
},
"hostname": "<MyHostName>",
"user_id": "",
"user_name": "",
"log_id": "90020201014091410270002070951766882711015226887425228818",
"_id": "90020201014091410270002070951766882711015226887425228818",
"isMobile": false
}
这个问题帮我解决了Failed Exchange
问题。将Auth0应用程序属性设置更改为:
应用程序类型:常规Web应用程序令牌终结点身份验证方法:无
然而,这发现了一个新问题..。
打破原木:Failed Silent Auth
发布于 2020-10-14 10:29:30
我在这里做了很多修正,所以我会在答案中记录它们。
登录期间的警告
这是通过确保正确设置了我的凭据提供程序来解决的。在这种情况下,谷歌。有关如何将google添加为凭据提供程序请看这里的说明。
失败的交换
这是通过转到auth0仪表板应用程序设置并将设置Application Type
修改为Regular Web Application
和将设置Token Endpoint Authentication Method
修改为None
来修复的。
成功登录(但不太成功)
一旦我修复了上面的Failed Exchange
,这个问题就消失了。
失败的沉默的八月
这从来没有“修复”,错误仍然出现在日志中。然而,对这个问题的评论促使我重新访问Allowed Web Origins
和auth0上的Allowed Origins (CORS)
,内容如下:
https://<mydomain>.eu.auth0.com, http://localhost:3000
这是链中的最后一个问题,我现在可以按预期使用登录和注销。
https://stackoverflow.com/questions/64349014
复制相似问题