我正在尝试使用以下端点通过 auth0 进行社交身份验证。
https://YOUR_NAMESPACE/authorize
该文档明确指出,鉴于response_type=token我们应该在散列片段中收到一个access_token和一个id_token。
https://auth0.com/docs/api/authentication#!#get--authorize_social
但无论出于何种原因,我只取回access_token. 登录似乎工作正常,并通过谷歌进行身份验证,但是当重定向到回调时,id_token只是丢失了。的access_token,state和token_type存在于-最少。
我已经使用了试图/oauth/access_token端点接受id_token给定的我已经有了access_token,但要做出这样的请求(我三重检查我做正确)总是产生一个401 unauthorized。
Auth0 显然是一个有价值的产品,所以我非常怀疑它直接不起作用。任何人都可以指出我正确的方向吗?到目前为止,谷歌搜索没有帮助。
我在Go中创建了一个应用程序,其中包含使用基于angular2的客户端的https服务器,使用auth0进行身份验证,我在Go中编写了另一个应用程序,即API服务器,此API服务器具有为auth0配置的jwt中间件,详情请参阅https:// auth0 .com/docs/quickstart/backend/golang.
现在......我想使用邮递员来测试我的API服务器的请求,但首先我需要进行身份验证.如何向我的网站添加身份验证以获取访问令牌或使用我的API请求转发的内容?
我阅读了文档,但我真的很困惑.任何有关该问题的信息将不胜感激.
使用Postman Mac App 4.4.2
谢谢!
所以我在登录到我的auth0帐户时在我的Postman Mac App上安装了Authentication API Collections.
现在,我正在尝试获取一个访问令牌,以便在发布到我的Api服务器时与身份验证标头一起使用.
我不知道在集合中应该使用哪种方法来获取访问令牌.
我开始开发Web应用程序并选择Angular 2作为前端框架.我目前正在尝试使用Auth0进行用户授权.问题如下:我正在尝试实现登录页面登录 - >重定向功能.打开网站后,应立即检查是否有用户的令牌localStorage,然后显示登录窗口小部件或重定向到主页.但我遇到了这个非常讨厌的错误:
当我登录时,页面刷新并且小部件再次出现:tokenNotExpired()由于某种原因返回false.我按下相同的凭据再次登录 - 页面刷新,登录小部件消失,现在tokenNotExpired()返回的日志显示true,但我的重定向仍然无法正常工作.如果我现在只输入我的基地址http://localhost:4200,它成功地将我重定向到home并tokenNotExpired()返回true.
我试过调试但没有运气 - 我找不到它失败的地方.
从本质上讲,由于我缺乏经验,我非常确定我在编写重定向功能时遇到了问题.我非常感谢任何帮助,一直坐在这上面.
我包含了省略冗余部分的代码摘录.我通过在main.ts中引导它来全局注入Auth服务.
app.routes.ts:
import {provideRouter, RouterConfig} from "@angular/router";
import {AuthGuard} from './secure/auth.guard';
import {AdminGuard} from "./secure/admin.guard";
import {UserHomeComponent} from "./main/user-cpl/user-home.component";
import {AdminHomeComponent} from "./main/admin-cpl/admin-home.component";
import {LoginPageComponent} from "./login/login-page.component";
const APP_ROUTES: RouterConfig = [
{ path: 'home', canActivate: [AuthGuard],
children: [
{ path: '', component: UserHomeComponent },
{ path: 'admin', component: AdminHomeComponent, canActivate: …Run Code Online (Sandbox Code Playgroud) 在此事先感谢您的帮助!
我希望有人可以帮我弄清楚如何通过Auth0授权扩展中分配的组来授权API访问.
我目前正在使用web api中的[Authorize]属性 - 它允许api调用,如果他们已成功登录并阻止它,如果没有.
但是,如果我尝试[Authorize(Roles ="myGroupName")]授权失败.如果我在Auth0网站上的用户仪表板中手动将其添加到用户app_metadata而不是通过扩展程序分配,则会出现相同的情况.
我的项目是通过遵循Angular Quick Start和Asp.Net Quick Start来设置的.我验证令牌服务器端的webapiconfig是:
class WebApiConfig
{
public static void Register(HttpConfiguration configuration)
{
var clientID = WebConfigurationManager.AppSettings["auth0:ClientId"];
var clientSecret = WebConfigurationManager.AppSettings["auth0:ClientSecret"];
configuration.MessageHandlers.Add(new JsonWebTokenValidationHandler()
{
Audience = clientID,
SymmetricKey = clientSecret
});
configuration.Routes.MapHttpRoute("API Default", "api/{controller}/{id}",
new { id = RouteParameter.Optional });
}
}
Run Code Online (Sandbox Code Playgroud) 我试图放入Auth0并在服务器上的现有REST API中替换登录和注册方法.当前系统使用电子邮件和密码.
为此,我正在使用Auth0作为后备存储来实现登录和注册端点.我通过我的Node.js服务器使用管理api成功创建了一个使用电子邮件和密码的用户.
var request = require("request");
var options = { method: 'POST',
url: 'https://test.auth0.com/api/v2/users',
headers:
{
'content-type': 'application/json',
authorization: 'Bearer SomeToken' },
body:
{ connection: 'Username-Password-Authentication',
email: 'test@yahoo.com',
password: 'test',
user_metadata: { enable_promotions: true },
email_verified: false,
app_metadata: {} },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Run Code Online (Sandbox Code Playgroud)
我一直试图弄清楚如何验证同一个用户.我在管理API上找不到身份验证方法,所以我尝试使用身份验证api,但它说用户名是必需的 - 在我的情况下,我通过电子邮件而不是用户名创建了用户.
a)我是否必须使用autentication API而不是管理API来使用密码和电子邮件进行身份验证?
b)我是否使用该电子邮件作为用户名?
伙计们,我正在浏览Auth0的VueJS教程,我收到了这个错误:
InvalidTokenError {message: "Invalid token specified: Cannot read property 'replace' of undefined"}
message:"Invalid token specified: Cannot read property 'replace' of undefined"
Run Code Online (Sandbox Code Playgroud)
教程如下:
https://auth0.com/blog/vuejs2-authentication-tutorial/
当应用程序调出Auth0 Lock小部件时,错误就会发生.
思考?
我很难获得Auth0以JWT格式返回访问令牌。我需要JWT格式的文件,以便可以使用Java JWT库进行验证。
我正在使用Auth0 lock登录,并用于/oauth/token获取访问令牌-我尝试将受众设置为我们的API标识符(包括锁定auth参数和/oauth/token有效负载在内的多个位置),但未成功-返回访问令牌,但未返回JWT。
或者,是否有一个Java库用于验证“本机” Auth0访问令牌?
var options = {
auth: {
redirectUrl: '<redirect_link>',
responseType: 'code',
params: {
audience: '<API_identifier>',
scope: 'openid offline_access'
}
},
allowedConnections: ['Username-Password-Authentication']
};
var lock = new Auth0Lock('<clientId>', '<auth0_Host>', options);
lock.show();
Run Code Online (Sandbox Code Playgroud)
返回的代码用于POST https://<host>/oauth/token与数据:
client_id=<client_id>&redirect_uri=<redirect_url>&client_secret=<client_secret>&code=<returned_code>&grant_type=authorization_code&audience=<API_identifier>
Run Code Online (Sandbox Code Playgroud)
哪个成功,但是访问令牌不是JWT,例如: "access_token":"sG99DAJI789SYgTj"
使用范围openid返回JWT格式的id_token,但是从阅读文档开始,不应将此令牌用于API授权。
我有一个 Swift 应用程序,它实现了 Auth0 的网络登录。成功登录后,我会收到一个访问令牌和idToken,它们都本地存储在我的钥匙串中。下次登录时,我首先检查访问令牌(存储在钥匙串中)是否仍然有效
Auth0
.authentication()
.userInfo(withAccessToken: accessToken)
.start { result in
switch result {
case .success(result: let profile):
print("access token still valid")
Run Code Online (Sandbox Code Playgroud)
成功后不必再次登录。然而,我遇到的问题是,即使我的访问令牌仍然有效,我的 idToken 可能已经过期,这会导致在我使用此 idToken 请求我的(GraphQL)后端时出错。那么我该如何解决这个问题?有没有办法检查我的 idToken 在 Swift 中是否已过期?因为如果没有办法检查,我将不得不要求登录,即使令牌可能没有过期。那没有意义。
我在angular-oauth2-oidc图书馆设置为使用与Auth0。但是,Auth0 不断向我发送一个非常短的访问令牌,例如mSNhEfdDHK6t-kT5QweRtgec-FPGAsdfEw9,而不是完整的 JWT 令牌。以下是重现问题的方法:
angular-oauth2-oidc或克隆我的示例 repo。按照以下方式配置它:
export const authConfig: AuthConfig = {
issuer: 'https://your-tenant-name.eu.auth0.com/',
clientId: 'your-spa-client-id-here',
redirectUri: window.location.origin + '/index.html',
scope: 'openid profile email',
};
Run Code Online (Sandbox Code Playgroud)initImplicitFlow()通过单击应用程序上的登录按钮触发调用。
当你这样做时:
Auth0 社区论坛上有一个线程,它解释了为什么您会为访问令牌获得这样一个“不透明字符串”。最重要的、被接受的答案提到了我已经在做的事情(sope就像我所做的那样,打电话/authorize等)。但是,在该线程的较低部分提到设置audience调用时/authorize是解决方案,无论如何这似乎是一件好事。
但是你如何发送audience?有上没有这样的属性的AuthConfig类型来设置它,看initImplicitFlow()它只是直线上升的变化源location.href,所以没有拦截有两种。
我正在对我的应用程序进行身份验证,并且已设法将登录名添加到我的页面。用户可以登录并存储他们的会话,但是一旦我刷新页面,他们的会话就消失了。ReactJs + NextJS
我知道有getTokenSilently但是当我调用它时它会返回它!
error: "login_required"
error_description: "Login required"
state: "N3B+aWt4T1dBeGlibWsua2ZkdX5LTzR6T19ndTdXfkJ2Tm5kUzJIY3lXTQ=="
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
useEffect(() => {
if (typeof window !== `undefined`) {
if (!loading && !isAuthenticated) {
loginWithRedirect({})
}
}
});
Run Code Online (Sandbox Code Playgroud)
<Button
className="account-button"
variant="textButton"
icon={<i className="flaticon-user" />}
aria-label="login"
title={loading ? 'loading' : isAuthenticated ? 'Hi' : 'login'}
/>
Run Code Online (Sandbox Code Playgroud)
// src/react-auth0-spa.js
import React, { useState, useEffect, useContext } from "react";
import createAuth0Client from "@auth0/auth0-spa-js";
const DEFAULT_REDIRECT_CALLBACK = () =>
window.history.replaceState({}, document.title, window.location.pathname);
export const Auth0Context = React.createContext(); …Run Code Online (Sandbox Code Playgroud)