如何使用空手道OAUTH 2.0授权授权类型获取访问令牌

发布于 2025-01-25 17:20:21 字数 1005 浏览 2 评论 0原文

我试图使用空手道框架自动化以下步骤,然后在邮递员中进行的步骤。 我在Postman中尝试的方式:

  1. ON授权选项卡选择OAuth 2.0
  2. 选择标头前缀载体
  3. 授予型是“隐式”,
  4. 我将回调URL放置
  5. 在我放置auth url
  6. 我放置client ID
  7. 选择“客户端身份验证”作为Send作为基本auth标头。

我使用以下代码以获取访问令牌 背景:

 * url 'Auth URL'

  Scenario: Verify the user details using OAuth2 Implicit grant type

    * form field callbackurl = 'callbackurl'
    * form field grant_type = 'implicit'
    * form field client_id = 'client id'
    * form field username = 'username'
    * form field password = 'password'
    * method post
    * status 200
    * print response

    * def accessToken = response.access_token

    * path 'resource'
    * header Authorization = 'Bearer ' + accessToken
# * param access_token = accessToken
    * method post
    * status 200

在输出中我得到 // Springboard的前端没有UserPoolid。我们不使用UserPoolid //无论如何,除了放置上下文数据外。 var userpoolid =“”; var clientid = geturlParameter(“ client_id”);

我不知道我在哪里错了。请提供您的帮助。谢谢!

I tried to automate using karate framework following steps which I did in postman.
How I tried in Postman:

  1. On Authorization tab select OAuth 2.0
  2. Select Header Prefix Bearer
  3. Grant-Type is "Implicit"
  4. I put Callback URL
  5. I put Auth URL
  6. I put Client ID
  7. Select "Client Authentication" as Send as Basic Auth Header.

I used following code in order to get Access token
Background:

 * url 'Auth URL'

  Scenario: Verify the user details using OAuth2 Implicit grant type

    * form field callbackurl = 'callbackurl'
    * form field grant_type = 'implicit'
    * form field client_id = 'client id'
    * form field username = 'username'
    * form field password = 'password'
    * method post
    * status 200
    * print response

    * def accessToken = response.access_token

    * path 'resource'
    * header Authorization = 'Bearer ' + accessToken
# * param access_token = accessToken
    * method post
    * status 200

In output I got
// UserpoolId is not available on frontend for springboard. We do not use userPoolId
// anyway other than put in context data.
var userPoolId = "";
var clientId = getUrlParameter("client_id");

I do not know where I am wrong. Please provide your help. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文