ตัวแปรโฟลว์ OAuth

คุณกำลังดูเอกสารประกอบของ Apigee Edge
ไปที่เอกสารประกอบของ Apigee X
ข้อมูล

Apigee Edge สรุปความสามารถของ OAuth 1.0a และ OAuth 2 ในชุดนโยบาย Apigee Edge ในการจัดการอายุการใช้งานของโทเค็นและข้อมูลลับ รวมถึงการสร้าง การตรวจสอบ และพื้นที่เก็บข้อมูลจะได้รับการจัดการโดย Apigee Edge ในนามของบริการแบ็กเอนด์

เอกสารนี้ระบุตัวแปรโฟลว์ที่กำหนดโดยนโยบาย OAuth ตัวแปรนี้ใช้เพื่อนำลักษณะการทำงานที่กำหนดเองสำหรับโฟลว์ OAuth ได้ สำหรับการใช้งาน OAuth โปรดดูที่ OAuth

ตัวแปรขั้นตอน OAuth 2.0

ระบบจะป้อนข้อมูลตัวแปรโฟลว์ที่กำหนดในตารางนี้เมื่อดำเนินการนโยบาย OAuth ที่เกี่ยวข้อง จึงพร้อมใช้งานสำหรับนโยบายหรือแอปพลิเคชันอื่นๆ ที่ดำเนินการในโฟลว์พร็อกซี API

ยืนยันนโยบายโทเค็นเพื่อการเข้าถึง
  • organization_name
  • organization_name
  • developer.id
  • developer.app.name
  • client_id
  • grant_type
  • token_type
  • access_token
  • accesstoken.{custom_attribute}
  • issued_at
  • expires_in
  • status
  • scope
  • apiproduct.name*
  • apiproduct.<custom_attribute_name>*

* ตัวแปรผลิตภัณฑ์ API

นโยบายตัวอย่าง

<OAuthV2 name="VerifyAccessToken">
    <Operation>VerifyAccessToken</Operation>
    <Scope>space-separated-scopes</Scope>*
    <AccessToken>flow.variable</AccessToken>*        
    <AccessTokenPrefix>Bearer</AccessTokenPrefix>*
</OAuthV2>

รองรับเฉพาะโทเค็นสำหรับผู้ถือเท่านั้น ไม่สนับสนุนโทเค็น MAC

โดยค่าเริ่มต้น คุณต้องส่งโทเค็นเพื่อการเข้าถึงในส่วนหัวคำขอ HTTP การให้สิทธิ์

เช่น

"Authorization: Bearer {PlainText_AccessToken}"

flow.variable ใดๆ สามารถส่งผ่านเป็น:

  • HTTP Header: request.header.{variable_name}
  • Query parameter: request.queryparam.{variable_name}
  • Form parameter: request.formparam.{variable_name}

หากไม่ได้ระบุช่องที่ไม่บังคับ ระบบจะแยกค่าตามข้อกำหนดของ OAuth 2.0

สร้างนโยบายรหัสการให้สิทธิ์
ตัวแปรที่ตั้งค่าเกี่ยวกับความสําเร็จ
  • oauthv2authcode.{policy_name}.code
  • oauthv2authcode.{policy_name}.redirect_uri
  • oauthv2authcode.{policy_name}.scope
  • oauthv2authcode.{policy_name}.client_id

นโยบายตัวอย่าง

<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>

* ไม่บังคับ

flow.variable ใดๆ สามารถส่งผ่านเป็น:

  • HTTP Header: request.header.{variable_name}
  • Query parameter: request.queryparam.{variable_name}
  • Form parameter: request.formparam.{variable_name}

หากไม่ได้ระบุช่องที่ไม่บังคับ ระบบจะแยกค่าตามข้อกำหนดของ OAuth 2.0

ค่าแอตทริบิวต์ได้มาจากตัวแปรโฟลว์ที่ระบุแบบไดนามิก หรือใช้ค่าเริ่มต้นในนโยบายแบบคงที่

หากระบุทั้ง 2 แบบ ตัวแปรโฟลว์จะมีลำดับความสำคัญเหนือกว่า

สร้างนโยบายโทเค็นเพื่อการเข้าถึงสำหรับรหัสการให้สิทธิ์ประเภทการให้สิทธิ์ ข้อมูลเข้าสู่ระบบของผู้ใช้ และข้อมูลเข้าสู่ระบบไคลเอ็นต์
ตัวแปรที่ตั้งค่าเกี่ยวกับความสําเร็จ
  • oauthv2accesstoken.{policy_name}.access_token
  • oauthv2accesstoken.{policy_name}.token_type
  • oauthv2accesstoken.{policy_name}.expires_in
  • oauthv2accesstoken.{policy_name}.refresh_token

นโยบายตัวอย่าง

<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>

* ไม่บังคับ

flow.variable ใดๆ สามารถส่งผ่านเป็น:

  • HTTP Header: request.header.{variable_name}
  • Query parameter: request.queryparam.{variable_name}
  • Form parameter: request.formparam.{variable_name}

หากไม่ได้ระบุช่องที่ไม่บังคับ ระบบจะแยกค่าตามข้อกำหนดของ OAuth 2.0

ค่าแอตทริบิวต์ได้มาจากตัวแปรโฟลว์ที่ระบุแบบไดนามิก หรือใช้ค่าเริ่มต้นในนโยบายแบบคงที่

หากระบุทั้ง 2 แบบ ตัวแปรโฟลว์จะมีลำดับความสำคัญเหนือกว่า

สร้างนโยบายโทเค็นเพื่อการเข้าถึงสำหรับประเภทการให้สิทธิ์โดยนัย
ตัวแปรที่ตั้งค่าเกี่ยวกับความสําเร็จ
  • oauthv2accesstoken.{policy_name}.access_token
  • oauthv2accesstoken.{policy_name}.token_type
  • oauthv2accesstoken.{policy_name}.expires_in
  • oauthv2accesstoken.{policy_name}.refresh_token

นโยบายตัวอย่าง

<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>

* ไม่บังคับ

flow.variable ใดๆ สามารถส่งผ่านเป็น:

  • HTTP Header: request.header.{variable_name}
  • Query parameter: request.queryparam.{variable_name}
  • Form parameter: request.formparam.{variable_name}

หากไม่ได้ระบุช่องที่ไม่บังคับ ระบบจะแยกค่าตามข้อกำหนดของ OAuth 2.0

ค่าแอตทริบิวต์ได้มาจากตัวแปรโฟลว์ที่ระบุแบบไดนามิก หรือใช้ค่าเริ่มต้นในนโยบายแบบคงที่

หากระบุทั้ง 2 แบบ ตัวแปรโฟลว์จะมีลำดับความสำคัญเหนือกว่า

รีเฟรชนโยบายโทเค็นเพื่อการเข้าถึง
ตัวแปรที่ตั้งค่าเกี่ยวกับความสําเร็จ
  • oauthv2accesstoken.{policy_name}.access_token
  • oauthv2accesstoken.{policy_name}.token_type
  • oauthv2accesstoken.{policy_name}.expires_in
  • oauthv2accesstoken.{policy_name}.refresh_token

นโยบายตัวอย่าง

<OAuthV2 name="RefreshAccessToken">
  <Operation>RefreshAccessToken</Operation>
  <ExpiresIn>1000<ExpiresIn>
  <GrantType>flow.variable</GrantType>*
  <RefreshToken>flow.variable</RefreshToken>*
</OAuthV2>

* ไม่บังคับ

flow.variable ใดๆ สามารถส่งผ่านเป็น:

  • HTTP Header: request.header.{variable_name}
  • Query parameter: request.queryparam.{variable_name}
  • Form parameter: request.formparam.{variable_name}

หากไม่ได้ระบุช่องที่ไม่บังคับ ระบบจะแยกค่าตามข้อกำหนดของ OAuth 2.0

รับนโยบายแอตทริบิวต์ของลูกค้า

นโยบายตัวอย่าง

<GetOAuthV2Info name="GetClientAttributes">
<ClientId ref="{variable_name}"/>
</GetOAuthV2Info>

นโยบายตัวอย่าง

<GetOAuthV2Info name="GetClientAttributes">
  <ClientId>{client_id}</ClientId>
</GetOAuthV2Info>
รับนโยบายแอตทริบิวต์โทเค็นเพื่อการเข้าถึง
ตัวแปรที่ตั้งค่าเกี่ยวกับความสําเร็จ
  • oauthv2accesstoken.{policy_name}.access_token
  • oauthv2accesstoken.{policy_name}.scope
  • oauthv2accesstoken.{policy_name}.refresh_token
  • oauthv2accesstoken.{policy_name}.accesstoken.{custom_attribute_name}
  • oauthv2accesstoken.{policy_name}.developer.id
  • oauthv2accesstoken.{policy_name}.developer.app.name
  • oauthv2accesstoken.{policy_name}.expires_in
  • oauthv2accesstoken.{policy_name}.status

นโยบายตัวอย่าง

<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