Oauth 2.0 如何使用OAuth 2.0获取RAML API的访问令牌
我正在使用RAML和API管理器处理Mule项目。 跟随 我使用API管理器来处理与以下特性相关的服务Oauth 2.0 如何使用OAuth 2.0获取RAML API的访问令牌,oauth-2.0,mule,raml,Oauth 2.0,Mule,Raml,我正在使用RAML和API管理器处理Mule项目。 跟随 我使用API管理器来处理与以下特性相关的服务 简单的安全管理器 OAuth 2.0提供程序和 OAuth 2.0访问令牌强制 我有一个单独的重定向流,它执行以下操作 将“状态”设置为302 将“位置”设置为下面的URL http://localhost:8081/org/oauth/token?grant_type=authorization_code&&;客户id=53a406c3e4b0624da8246eed&a
- 简单的安全管理器
- OAuth 2.0提供程序和
- OAuth 2.0访问令牌强制
http://localhost:8081/org/oauth/token?grant_type=authorization_code&&;客户id=53a406c3e4b0624da8246eed&;client_secret=myclientsecret&;代码=#[message.inboundProperties.code]&;重定向\u uri=http://localhost:8081/raml-带有oauth/重定向的api
#%RAML 0.8
title: raml-api-with-oauth
version: v1
baseUri: http://localhost:8081/raml-api-with-oauth
securedBy: [oauth_2_0]
securitySchemes:
- oauth_2_0:
description: |
This supports OAuth 2.0 for authenticating all API requests.
type: OAuth 2.0
describedBy:
headers:
Authorization:
description: |
Used to send a valid OAuth 2 access token. Do not use
with the "access_token" query string parameter.
type: string
queryParameters:
access_token:
description: |
Used to send a valid OAuth 2 access token. Do not use together with
the "Authorization" header
type: string
responses:
401:
description: |
Bad or expired token. This can happen if the user or Dropbox
revoked or expired an access token. To fix, you should re-
authenticate the user.
403:
description: |
Bad OAuth request (wrong consumer key, bad nonce, expired
timestamp...). Unfortunately, re-authenticating the user won't help here.
404:
description: Unauthorized
settings:
authorizationUri: org/oauth/authorize
accessTokenUri: org/oauth/token
authorizationGrants: [code,token]
scopes:
- "READ_RESOURCE"
- "POST_RESOURCE"
- basic
- comments
- relationships
- likes
mediaType: application/json
/employee:
get:
description:
This is a Get Call which throws some response in json.
responses:
200:
body:
application/json:
example: |
{
"empcode" : 1,
"ename": "Rafiq",
"company" : "org"
}
Oauth政策基于Mule Enterprise security,为了了解不同类型赠款的风险,请参阅本文档页:
下面的代码代表oauth 2.0(raml 1.0)
安全方案:
oauth_2_0:
说明:|
此API支持OAuth 2.0对所有API请求进行身份验证。
类型:OAuth2.0
描述人:
标题:
授权:
说明:|
用于发送有效的OAuth 2访问令牌。不要与“访问令牌”查询一起使用
字符串参数。
类型:字符串
查询参数:
访问令牌:
说明:|
用于发送有效的OAuth 2访问令牌。请勿与“授权”一起使用
标题
类型:字符串
响应:
401:
说明:|
无效或过期的令牌。如果用户或API撤销或过期
访问令牌。要修复此问题,您应该重新验证用户。
403:
说明:|
错误的OAuth请求(错误的使用者密钥、错误的nonce、过期的时间戳…)。不幸的是,
重新验证用户在这里没有帮助。
设置:
authorizationUri:插入\u OAUTH2\u AUTHORIZATION\u URI
accessTokenUri:插入\u OAUTH2\u访问\u令牌\u URI
授权授予:插入授权授予
范围:[读,写]
- 在raml中包含此代码后,我们需要提供验证 oauth策略中的url。非统组织 供应商) 或者oauth提供程序应该给出 raml(授权和访问令牌和验证url) 可以使用oauth强制执行这些资源,以便使其更加灵活 确保共享资源 从raml生成流之后,我们需要部署 应用程序到cloudhub 我们需要提供组织客户id和客户机密,以便 它将提供访问令牌,否则会抛出错误的客户端