如何使用消费者密钥/秘密从 WSO2 获取 OAuth 令牌? [英] How do I obtain an OAuth token from WSO2 using the Consumer Key/Secret?

查看:68
本文介绍了如何使用消费者密钥/秘密从 WSO2 获取 OAuth 令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 WSO2 非常陌生,并且仍在对其进行评估 - 主要是通过 Fiddler.我的理解是,我应该能够通过调用 WSO2 的登录 API 来获取 OAuth 令牌.我尝试了以下各种 URL(在 Fiddler 中):

I am very new to WSO2 and am still evaluating it - mostly through Fiddler. It is my understanding that I should be able to obtain an OAuth token by calling WSO2's Login API. I have attempted various URLs (in Fiddler) along the lines of:

//基于博客文章:http://lalajisureshika.blogspot.com/2012/11/generate-application-tokens-user-tokens.html

http://localhost:8280/login?grant_type=password&username=admin&password=admin&scope=PRODUCTION
Authorization: Basic cFNET0lab1RnMHRBODRCWmQ4bTRBbnp1c0RZYTpZREIzZzh3RXhQOV92ZTdZX1drYVhieWx5ZlVh

当我执行上述 URL 时,我收到 (403) 在给定请求的 API 中找不到匹配的资源.

When I execute the above URL, I receive (403) No matching resource found in the API for the given request.

我可以使用访问令牌"(通过不记名标签)并且 API 可以工作.我只是不知道如何获取 OAuth 令牌以供实际运行时使用.

I can use the the "Access Token" (via the Bearer tag) and the APIs work. I just can't figure out how to obtain the OAuth token for actual runtime use.

有任何建议/想法吗?

--- 谢谢,杰夫

推荐答案

  1. 设置身份服务器 [domain:9443]
  2. 创建 OAuth2 应用程序,并获取客户端 ID + 消费者密钥
  3. 获取 clientId:consumerKey 的 Base64 编码 - 将其替换为 Authorization Basic xxxxx
  4. 替换用于生成令牌的 REST 端点 - 这应该在管理控制台上的 oauth 应用程序中获得 [在我们的例子中是 https://domain:9443/oauth2/token]

下面的 curl 命令应该会给你响应

And below curl command should give you the response

curl -k -d "grant_type=password&username=sasikumar@domain.com&password=xxxx1234" -H "Authorization" -H "Authorization: Basic X2dhWllidkN6TDNQY2ZqSmVBQ1lsNlg2SFdRYTpSQVlSMmxOZzQ0enU5ZXVGSDRDVXdOUWRudlVh, Content-type=application/x-www-form-urlencoded"  https://domain:9443/oauth2/token

这篇关于如何使用消费者密钥/秘密从 WSO2 获取 OAuth 令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆