我尝试将 Auth0 用于 android 我想我已经完成了一切,但仍然出现此错误:
E/LockActivity: Failed to authenticate the user: An error occurred when trying to authenticate with the server.
com.auth0.android.authentication.AuthenticationException: An error occurred when trying to authenticate with the server.
...
Run Code Online (Sandbox Code Playgroud)
我的运行身份验证类:
package com.my.awesome.app.modules;
public class AuthZeroModule extends ReactContextBaseJavaModule {
private ReactApplicationContext mReactContext;
private Lock mLock;
public AuthZeroModule(ReactApplicationContext reactContext) {
super(reactContext);
mReactContext = reactContext;
}
@Override
public String getName() {
return "AuthZero";
}
@ReactMethod
public void authenticate() {
Log.e("LSA", "=============authenticate");
Log.e("LSA", "=============CLIENT: " + AUTH0_CLIENT + " DOMAIN: …Run Code Online (Sandbox Code Playgroud) 在使用 auth0 PHP SDK 进行身份验证后,我正在努力获取用户信息。这是在我的本地主机上使用 ngrok。我只是使用 SDK 中的基本示例文件,我可以正常登录。但是,登录后,当它重定向到我的回调 url 并尝试交换身份验证代码时,我收到“未经授权”的 401 错误。
这是 wamp 中的错误:
在日志中,我可以看到登录成功,但是在尝试交换身份验证代码时,它失败了。
我还可以确认我正在获取查询参数中的代码和状态:
https://myurl.ngrok.io/auth/?code=ygKukP3B5_xk0pbb&state=5ae5b7a643aa46.52329844
Run Code Online (Sandbox Code Playgroud)
在尝试使其工作时,我对示例文件进行了一些轻微修改,但我认为这不是罪魁祸首。以防万一,这里是代码:
require 'vendor/autoload.php';
//require 'dotenv-loader.php';
use Auth0\SDK\Auth0;
$domain = 'mydomain.auth0.com';
$client_id = 'MYCLIENT';
$client_secret = 'MYSECRET';
$redirect_uri = 'https://myurl.ngrok.io/auth/';
$auth0 = new Auth0([
'domain' => $domain,
'client_id' => $client_id,
'client_secret' => $client_secret,
'redirect_uri' => $redirect_uri,
'persist_id_token' => true,
'persist_refresh_token' => true,
'audience' => 'https://mydomain.auth0.com/userinfo',
'scope' => 'openid profile'
]);
if (isset($_REQUEST['logout'])) {
$auth0->logout();
session_destroy();
header("Location: /");
die();
}
if(isset($_REQUEST['code'])) {
$userInfo = …Run Code Online (Sandbox Code Playgroud) 当我使用浏览器路由实现此代码时,它可以完美运行,但是当我使用哈希路由使用相同的代码时,它将无法正常工作。
import React from 'react';
import { Route,Router } from 'react-router-dom';
import App from './App';
import Home from './Home/Home';
import Callback from './Callback/Callback';
import Auth from './Auth/Auth';
import history from './history';
const auth = new Auth();
const handleAuthentication = ({location}) => {
if (/access_token|id_token|error/.test(location.hash)) {
auth.handleAuthentication();
}
}
export const makeMainRoutes = () => {
return (
<Router history={history}>
<div>
<Route path="/" render={(props) => <App auth={auth} {...props} />} />
<Route path="/home" render={(props) => <Home auth={auth} {...props} />} />
<Route path="/callback" …Run Code Online (Sandbox Code Playgroud)我的问题是我使用 auth0 作为我的身份验证服务,现在当用户登录并通过身份验证时,它会被重定向回我的回调 url,然后决定将用户发送到哪里现在我的问题是当你被重定向回你的回调时来自 auth0 的 url 在 url 字符串中有 queryParams,就像这样..
http://localhost:4200/account/login/callback#access_token="dsadsadsadsa dasdsaa"只是作为一个例子,但在一瞬间,查询字符串被删除,http://localhost:4200现在它离开了我试图使用这种方法获取查询参数
this.activatedRoute.queryParams.subscribe(params => {
console.log(params);
});
Run Code Online (Sandbox Code Playgroud)
现在这应该可以工作,但是每次 console.log 都是一个空对象,我认为这是因为发生的 url 更改..
有什么方法可以在删除之前获取查询参数?
编辑
基本上发生的事情是我正在通过身份验证然后我被重定向到
localhost:4200/account/login/callback?acessToken="dasdasdaefssves"
但随后路线更改为
localhost:4200/account/login/callback
在activatedRoute函数有机会运行之前没有查询参数!
任何帮助,将不胜感激!
我在 Auth0 中启用了用户/密码连接,我希望在继续之前验证电子邮件。我启用了相应的规则来强制电子邮件验证,一切似乎都按预期工作。
不过,我注意到在注册时发送了验证电子邮件。我想要一个按钮来允许再次发送该电子邮件,但这似乎不可能。
用户如何从 UI 请求验证电子邮件?
调用https://<tenantName>.auth0.com/api/v2/jobs/verification-email不起作用,因为令牌需要update:users范围。我们可以通过对 的请求获得具有该范围的令牌https://<tenantName>.auth0.com/oauth/token,但这意味着客户端机密将被公开。
我需要在Flutter 中使用Auth0,但 Auth0 站点中没有这样的 SDK。
Auth0致力于为 Flutter创建这样的SDK。
有没有人在 Flutter 中使用过 Auth0 或者你有什么建议?
我正在尝试向我的 React Native 应用程序添加 auth0 身份验证。我正在遵循此快速入门指南:https : //auth0.com/docs/quickstart/native/react-native
我正在连接到客户端设置的“常规 Web 应用程序”应用程序,并运行以下代码:
auth0
.webAuth
.authorize({scope: 'openid profile email', audience: 'https://YOUR_DOMAIN/userinfo'})
Run Code Online (Sandbox Code Playgroud)
(YOUR_DOMAIN替换为我的域)
它成功加载了 auth0 通用登录屏幕。如果我输入错误的用户名或密码,它会通知我。当我输入正确的用户名/密码时,它会关闭 auth0 通用登录屏幕并返回到我的应用程序,但它给了我以下错误:
AuthError {
name: "access_denied",
message: "Unauthorized",
json: Object,
status: 401,
stack: "Error? at responseHandler (blob:file:///7a27baf…:///7a27baff-5c83-48e3-a170-0137ed982e99:2563:13)"
}
Run Code Online (Sandbox Code Playgroud)
我从堆栈跟踪中知道该错误是由该authorize()方法引发的。
任何想法可能来自哪里?
谢谢!
我们正在构建一个带有 React/Redux 前端和 NodeJS/Express 后端的应用程序。我不是安全专家,而是选择使用 Auth0 来处理身份验证。
当用户登录时,Auth0 会返回一个 ID 令牌和一个访问令牌,此访问令牌用于验证和访问我们的后端 API。
我们已经看到这个访问令牌之前存储在本地存储中,但 Auth0 然后与此处相矛盾。此外,在这个答案中,似乎有些人建议将其存储在 Local Storage 中,就像this one 一样。
这让我非常困惑。我们如何在不将其存储在内存中的情况下存储和持久化令牌?我们只能将它存储在 Redux 中,但它会在刷新时清除,这不是解决方案。
在这里,他们显示用户登录并返回访问令牌,稍后它将与 API 请求一起发送,我理解,但同时将其存储在哪里?
我们应该如何存储访问令牌以便我们的应用程序可以访问我们的 API?或者我们根本不应该存储它?
描述
我有一个非常标准SPA的内置vue.js我使用其中Auth0通过以下的处理认证部正式例子。应用流程如下:
Register in the Initial.vue via Auth0 lock-> Callback is called->User's redirected to /home
上述流程中的所有内容都可以正常工作,但问题在于:
问题
一旦用户注册并且/home我希望他能够访问所有其他路由(例如/doctors),如果经过身份验证,如果没有,他应该提示他再次登录。根据上面的链接,这是在router.beforeEach函数中处理的。
访问/登录页面 ( Initialvue)时出现我的问题。当用户已经注册并尝试访问该路线时,我希望他被重定向到/home并跳过该login页面。我试过用beforeEnter路由来实现它,但auth.isAuthenticated由于为tokenExpiry空而失败(即使用户已经过身份验证!
代码
我的AuthService.js:
import auth0 from 'auth0-js';
import EventEmitter from 'events';
import authConfig from '../config/auth_config.json';
const webAuth = new auth0.WebAuth({
domain: authConfig.domain,
redirectUri: `${window.location.origin}/callback`,
clientID: authConfig.clientId, …Run Code Online (Sandbox Code Playgroud) auth0 ×10
reactjs ×3
javascript ×2
jwt ×2
access-token ×1
android ×1
angular ×1
asp.net-core ×1
auth0-lock ×1
callback ×1
email ×1
flutter ×1
oauth-2.0 ×1
php ×1
react-native ×1
react-router ×1
redux ×1
typescript ×1
verification ×1
vue-router ×1
vuejs2 ×1
vuetify.js ×1