更新时间:2023-10-20 16:36:22
如果要避免显示同意屏幕并重定向到auth0托管的登录页面,则可以将身份验证API与
If you want to avoid the consent screen and redirection to auth0 hosted login page, you can use authentication API with password-realm grant type. The disadvantages are:
如上所述:
身份验证API公开了Auth0的AuthN/AuthZ功能以及受支持的身份协议,如OpenID Connect,OAuth 2.0和SAML.我们建议您使用托管登录页面,但是如果您希望构建自己的UI,则可以使用我们的API端点来进行.但是,默认情况下会禁用某些Auth流(Grant类型),因此您需要按照本指南中的说明通过Auth0仪表板启用它们.
The Authentication API exposes AuthN/AuthZ functionality of Auth0, as well as the supported identity protocols like OpenID Connect, OAuth 2.0, and SAML. We recommend using our Hosted Login Page but if you wish to build your own UI you can use our API endpoints to do so. However some Auth flows (Grant types) are disabled by default so you will need to enable them via your Auth0 Dashboard as explained in this guide.
登录:
Auth0.authentication()
.login(
usernameOrEmail: "support@auth0.com",
password: "secret-password",
realm: "Username-Password-Authentication",
scope: "openid"
)
.start { result in
switch result {
case .success(let credentials):
print("Obtained credentials: \(credentials)")
case .failure(let error):
print("Failed with \(error)")
}
}
注册:
Auth0.authentication()
.createUser(
email: "support@auth0.com",
password: "secret-password",
connection: "Username-Password-Authentication",
userMetadata: ["first_name": "First",
"last_name": "Last"]
)
.start { result in
switch result {
case .success(let user):
print("User Signed up: \(user)")
case .failure(let error):
print("Failed with \(error)")
}
}
此处记录如下: https://github.com/auth0/Auth0.swift#authentication-api-ios--macos--tvos