<ph type="x-smartling-placeholder"></ph>
您正在查看 Apigee Edge 文档。
转到
Apigee X 文档。 信息
Apigee Edge 将 OAuth 1.0a 和 OAuth 2 功能封装在一组政策中。生活 令牌和密钥的周期管理,包括生成、验证和存储, 由 Apigee Edge 代表的后端服务。
本文档介绍了 OAuth 政策定义的流变量。变量可以是 来为 OAuth 流程实现自定义行为。如需了解 OAuth 的用法,请参阅 OAuth。
OAuth 2.0 流程变量
此表中定义的流变量在执行相应的 OAuth 政策时填充,因此可供在 API 代理流中执行的其他政策或应用使用。
验证访问令牌政策 |
* API 产品变量 |
示例政策: <OAuthV2 name="VerifyAccessToken"> <Operation>VerifyAccessToken</Operation> <Scope>space-separated-scopes</Scope>* <AccessToken>flow.variable</AccessToken>* <AccessTokenPrefix>Bearer</AccessTokenPrefix>* </OAuthV2> 仅支持不记名令牌。不支持 MAC 令牌。 默认情况下,访问令牌必须在授权 HTTP 请求中传递 标头。 例如:
任何
如果未指定可选字段,系统将根据 OAuth 2.0 提取值 规范 |
生成授权代码政策 |
成功设置的变量:
<ph type="x-smartling-placeholder">
|
示例政策: <OAuthV2 name="GetAuthCode"> <Operation>GenerateAuthorizationCode</Operation> <ExpiresIn>1000<ExpiresIn> <ResponseType>flow.variable</ResponseType>* <ClientId>flow.variable</ClientId>* <RedirectUri>flow.variable</RedirectUri>* <Scope>flow.variable</Scope>* <State>flow.variable</State>* <Attributes>* <Attribute name=”1” ref=”flow.variable”>value1</Attribute> <Attribute name=”2” ref=”flow.variable”>value2</Attribute> </Attributes> </OAuthV2> * 选填 任何
如果未指定可选字段,系统将根据 OAuth 2.0 提取值 规范 属性值由指定的流变量动态派生,或者 静态使用政策中的默认值。 如果两个都指定,则数据流变量优先。 |
为授权类型、授权代码、用户凭据 客户端凭据 |
成功设置的变量:
<ph type="x-smartling-placeholder">
|
示例政策: <OAuthV2 name="GenerateAccessToken"> <Operation>GenerateAccessToken</Operation> <ExpiresIn>1000<ExpiresIn> <SupportedGrantTypes>* <GrantType>authorization_code</GrantType> <GrantType>password</GrantType> <GrantType>client_credentials</GrantType> </SupportedGrantTypes> <GrantType>flow.variable</GrantType>* <ClientId>flow.variable</ClientId>* <RedirectUri>flow.variable</RedirectUri>* <Scope>flow.variable</Scope>* <AppEndUser>flow.variable</AppEndUser>* <Code>flow.variable</Code>* <UserName>flow.variable</UserName>* <PassWord>flow.variable</PassWord>* <Attributes>* <Attribute name=”1” ref=”flow.variable”>value1</Attribute> <Attribute name=”2” ref=”flow.variable”>value2</Attribute> </Attributes> </OAuthV2> * 选填 任何
如果未指定可选字段,系统将根据 OAuth 2.0 提取值 规范 属性值由指定的流变量动态派生,或者 静态使用政策中的默认值。 如果两个都指定,则数据流变量优先。 |
为隐式授权类型生成访问令牌政策 |
成功设置的变量:
<ph type="x-smartling-placeholder">
|
示例政策: <OAuthV2 name="GenerateAccessToken"> <Operation>GenerateAccessTokenImplicitGrant</Operation> <ExpiresIn>1000<ExpiresIn> <ResponseType>flow.variable></ResponseType>* <ClientId>flow.variable></ClientId>* <RedirectUri>flow.variable></RedirectUri>* <Scope>flow.variable></Scope>* <State>flow.variable></State>* <AppEndUser>flow.variable</AppEndUser>* <Attributes>* <Attribute name=”1” ref=”flow.variable”>value1</Attribute> <Attribute name=”2” ref=”flow.variable”>value2</Attribute> </Attributes> </OAuthV2> * 选填 任何
如果未指定可选字段,系统将根据 OAuth 2.0 提取值 规范 属性值由指定的流变量动态派生,或者 静态使用政策中的默认值。 如果两个都指定,则数据流变量优先。 |
刷新访问令牌政策 |
成功设置的变量:
<ph type="x-smartling-placeholder">
|
示例政策: <OAuthV2 name="RefreshAccessToken"> <Operation>RefreshAccessToken</Operation> <ExpiresIn>1000<ExpiresIn> <GrantType>flow.variable</GrantType>* <RefreshToken>flow.variable</RefreshToken>* </OAuthV2> * 选填 任何
如果未指定可选字段,系统将根据 OAuth 2.0 提取值 规范 |
获取客户端属性政策 |
示例政策: <GetOAuthV2Info name="GetClientAttributes"> <ClientId ref="{variable_name}"/> </GetOAuthV2Info> 示例政策: <GetOAuthV2Info name="GetClientAttributes"> <ClientId>{client_id}</ClientId> </GetOAuthV2Info> |
获取访问令牌特性政策 |
成功设置的变量:
<ph type="x-smartling-placeholder">
|
示例政策: <GetOAuthV2Info name="GetTokenAttributes"> <AccessToken ref="{variable_name}"/> </GetOAuthV2Info> 示例政策: <GetOAuthV2Info name="GetTokenAttributes"> <AccessToken>{access_token}</AccessToken> </GetOAuthV2Info> |
获取授权代码属性政策 |
示例政策: <GetOAuthV2Info name="GetAuthCodeAttributes"> <AuthorizationCode ref="{variable_name}"/> </GetOAuthV2Info> 示例政策: <GetOAuthV2Info name="GetAuthCodeAttributes"> <AuthorizationCode>{authorization_code}</AuthorizationCode> </GetOAuthV2Info> |
获取刷新令牌属性政策 |
示例政策: <GetOAuthV2Info name="GetTokenAttributes"> <RefreshToken ref="{variable_name}"/> </GetOAuthV2Info> 示例政策: <GetOAuthV2Info name="GetTokenAttributes"> <RefreshToken>{refresh_token}</RefreshToken> </GetOAuthV2Info> |
OAuth 1.0a 流程变量
此表中定义的流变量在执行相应的 OAuth 政策时填充,因此可供在 API 代理流中执行的其他政策或应用使用。
生成请求令牌政策
示例政策:
<OAuthV1 name="GenerateRequestToken"> <Operation>GenerateRequestToken</Operation> </OAuthV1>
成功设置的变量:
oauth_token
oauth_token_secret
oauth_callback_confirmed
oauth_response
oauth_consumer_key
oauth_consumer_secret
生成访问令牌政策
示例政策:
<OAuthV1 name="GenerateAccessToken"> <Operation>GenerateAccessToken</Operation> </OAuthV1>
成功设置的变量:
oauth_token
oauth_token_secret
oauth_response
oauth_consumer_key
oauth_consumer_secret
访问令牌验证 政策
示例政策:
<OAuthV1 name="VerifyAccessToken"> <Operation>VerifyAccessToken</Operation> </OAuthV1>
成功设置的变量:
oauth_token
oauth_token_secret
oauth_response
oauth_consumer_key
oauth_consumer_secret
验证 API 密钥政策
示例政策:
<GetOAuthV1Info name="VerifyApiKey"> <OAuthConfig>{config_name}</OAuthConfig>* <APIKey ref="{variable_name}" /> </GetOAuthV1Info>
* 选填
成功设置的变量:
oauth_consumer_key
oauth_consumer_secret
验证使用方政策
示例政策:
<GetOAuthV1Info name="VerifyConsumer"> <OAuthConfig>{config_name}</OAuthConfig>* <ConsumerKey ref="{variable_name}" /> </GetOAuthV1Info>
* 选填
成功设置的变量:
oauth_consumer_key
oauth_consumer_secret
验证令牌政策
示例政策:
<GetOAuthV1Info name="VerifyToken"> <OAuthConfig>{config_name}</OAuthConfig>* <RequestToken ref="{variable_name}" /> </GetOAuthV1Info>
* 选填
成功设置的变量:
oauth_token
oauth_token_secret