使用 auth0 登录 acess_token 到邮递员
getting login acess_token with auth0 to postman
我在 Go 中创建了一个应用程序,其中包括 https 服务器和基于 angular2 的客户端,该客户端使用 auth0 进行身份验证,
我有另一个用 Go 编写的应用程序,它是 API 服务器,这个 API 服务器在 https://auth0.com/docs/quickstart/backend/golang.
解释时为 auth0 配置了 jwt 中间件
现在...我想使用邮递员来测试我的 API 服务器的请求,但首先我需要进行身份验证。如何向我的网站添加身份验证以获取访问令牌或转发我的 API 请求的内容?
我阅读了文档,但我真的很困惑。
任何有关此问题的信息将不胜感激。
使用 Postman Mac 应用程序 4.4.2
谢谢!
更新
所以我在我的 Postman Mac 应用程序上安装了身份验证 API Collections,同时登录到我的 auth0 帐户。
现在我正在尝试获取一个访问令牌,以便在发布到我的 Api 服务器时用于身份验证 header。
我不知道应该在 collection 中使用哪种方法来获取访问令牌。
以下是一些测试基于 JWT 的 API 的方法:https://auth0.com/docs/local-testing-and-development#client-side-applications-and-jwt
Client-side applications and JWT
This is usually the easiest scenario to test. One of the benefits of
JSON Web Tokens is that they are stateless, which means that an
application that consumes them only cares about the JWT's contents and
not any previous state such as a session cookie.
There are mainly three approaches to obtaining JWTs for testing:
Manually generate a JWT with the needed data, and sign it with your
Auth0 application's client secret. If you omit the exp claim from a
token, most JWT libraries will interpret it as a token which never
expires, though it's possible some libraries might reject it. The
benefit of this approach is that it does not require Internet access
or intervention from Auth0 at all.
Create a dummy user in a database connection, and programatically log
in with this user through the resource owner endpoint. In order to get
a JWT back, make sure to set the correct scope
value. The benefit of
this approach is that it will execute any rules that you have
configured on your Auth0 account.
Use a browser bot (e.g. Selenium) which logs a dummy user in and
retrieves a JWT. This approach may take some effort to develop and
maintain, but it will also execute any redirection rules or MFA prompts that you have configured on your Auth0 account.
我在 youtube 上找到了关于如何使用 postman 使用用户名和密码凭据登录数据库连接的教程。
https://www.youtube.com/watch?v=VDUzBn6SzIY
所以我安装了 Auth0 身份验证 API collection,并打开了数据库连接 -> 使用用户名和密码登录。
所以我用相关参数(client_id、用户名、密码、连接)保存了 post 请求,我只是先用它来获取访问令牌,然后将其粘贴到授权header 以便从 Api 服务器获取信息。
它既有趣又棘手:)
首先你需要使用 Postman 从 Auth0 获取令牌,记住你可以从 Auth0 的应用程序设置中获取任何信息
在上图中,您看到 id_token 和 access_token。这里的技巧是使用 Id_token 来发送你的请求,而不是 Access_token。做如下:
如您所见,对于发送到 API 的任何请求,我们需要添加一个名为 Authorization 的 header,其值为 "Bearer {id_token}"。繁荣......工作完成:)希望它有帮助
我在 Go 中创建了一个应用程序,其中包括 https 服务器和基于 angular2 的客户端,该客户端使用 auth0 进行身份验证, 我有另一个用 Go 编写的应用程序,它是 API 服务器,这个 API 服务器在 https://auth0.com/docs/quickstart/backend/golang.
解释时为 auth0 配置了 jwt 中间件现在...我想使用邮递员来测试我的 API 服务器的请求,但首先我需要进行身份验证。如何向我的网站添加身份验证以获取访问令牌或转发我的 API 请求的内容?
我阅读了文档,但我真的很困惑。 任何有关此问题的信息将不胜感激。
使用 Postman Mac 应用程序 4.4.2
谢谢!
更新
所以我在我的 Postman Mac 应用程序上安装了身份验证 API Collections,同时登录到我的 auth0 帐户。
现在我正在尝试获取一个访问令牌,以便在发布到我的 Api 服务器时用于身份验证 header。
我不知道应该在 collection 中使用哪种方法来获取访问令牌。
以下是一些测试基于 JWT 的 API 的方法:https://auth0.com/docs/local-testing-and-development#client-side-applications-and-jwt
Client-side applications and JWT
This is usually the easiest scenario to test. One of the benefits of JSON Web Tokens is that they are stateless, which means that an application that consumes them only cares about the JWT's contents and not any previous state such as a session cookie.
There are mainly three approaches to obtaining JWTs for testing:
Manually generate a JWT with the needed data, and sign it with your Auth0 application's client secret. If you omit the exp claim from a token, most JWT libraries will interpret it as a token which never expires, though it's possible some libraries might reject it. The benefit of this approach is that it does not require Internet access or intervention from Auth0 at all.
Create a dummy user in a database connection, and programatically log in with this user through the resource owner endpoint. In order to get a JWT back, make sure to set the correct
scope
value. The benefit of this approach is that it will execute any rules that you have configured on your Auth0 account.Use a browser bot (e.g. Selenium) which logs a dummy user in and retrieves a JWT. This approach may take some effort to develop and maintain, but it will also execute any redirection rules or MFA prompts that you have configured on your Auth0 account.
我在 youtube 上找到了关于如何使用 postman 使用用户名和密码凭据登录数据库连接的教程。
https://www.youtube.com/watch?v=VDUzBn6SzIY
所以我安装了 Auth0 身份验证 API collection,并打开了数据库连接 -> 使用用户名和密码登录。
所以我用相关参数(client_id、用户名、密码、连接)保存了 post 请求,我只是先用它来获取访问令牌,然后将其粘贴到授权header 以便从 Api 服务器获取信息。
它既有趣又棘手:)
首先你需要使用 Postman 从 Auth0 获取令牌,记住你可以从 Auth0 的应用程序设置中获取任何信息
在上图中,您看到 id_token 和 access_token。这里的技巧是使用 Id_token 来发送你的请求,而不是 Access_token。做如下:
如您所见,对于发送到 API 的任何请求,我们需要添加一个名为 Authorization 的 header,其值为 "Bearer {id_token}"。繁荣......工作完成:)希望它有帮助