[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eThis documentation applies to both Apigee and Apigee hybrid platforms, covering various OAuth-related features.\u003c/p\u003e\n"],["\u003cp\u003eWhen using the authorization code grant type, multiple redirect URIs can be specified as a comma-separated list in the developer app's Callback URL field for authenticating across multiple domains.\u003c/p\u003e\n"],["\u003cp\u003eThe GenerateAuthCode operation's default 302 redirect behavior can be customized to return a 200 response with structured JSON containing the code, using ExtractVariables and AssignMessage policies.\u003c/p\u003e\n"],["\u003cp\u003eThe Apigee Audit API enables the verification of end-user consent for app authorization.\u003c/p\u003e\n"],["\u003cp\u003eThe outbound-oauth sample, available in the Apigee api-platform-samples repository on GitHub, demonstrates obtaining and caching OAuth access tokens for outbound API calls.\u003c/p\u003e\n"]]],[],null,["# Advanced OAuth 2.0 topics\n\n*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nUsing third-party OAuth tokens\n------------------------------\n\nSee [Using third-party\nOAuth tokens](/apigee/docs/api-platform/security/oauth/use-third-party-oauth-system).\n\nDesignating multiple redirect URIs\n----------------------------------\n\nWhen using the authorization code grant type, you must specify a redirect URI when you\nregister your developer app. The redirect URI specifies the URI of an app that is\ndesignated to receive an authorization code on behalf of the client app. The client is required to send this URI to Apigee when\nrequesting authorization codes and tokens, and the `redirect_uri` parameter must match the\none that is registered. See also [Get OAuth 2.0 tokens](/apigee/docs/api-platform/security/oauth/access-tokens).\n\nFor example: \n\n```\nhttps://mydomain.com/authorize?\\\nclient_id=123456&\\\nresponse_type=code&\\\nredirect_uri=https%3A%2F%2Fmydomain.com%2Fcallback&scope=scope1%20scope2&state=abc\n```\n\nThere is a use case for specifying multiple redirect URIs in a single proxy application. For\nexample, you may want to authenticate for multiple domains. For instance:\n\n- `https://mydomain.com/callback`\n- `https://mydomain.uk/callback`\n- `https://mydomain.ja/callback`\n\nTo specify multiple redirect URIs in the developer app, add them as a comma-separated list\nin the **Callback URL** field in the developer app UI. For example: \n\n```\nhttps://mydomain.com/callback,https://mydomain.uk/callback,https://mydomain.ja/callback\n```\n\n\nNote that the `/authorize` request must only carry **one** URI in the `redirect_uri` parameter.\nAs long as the redirect URI matches one of the URIs specified in the **Callback URL** field in developer app UI,\nthe request will succeed.\n\nChanging the default return\nbehavior of a GenerateAuthCode operation\n--------------------------------------------------------------------\n\nBy default, the GenerateAuthCode operation of the [OAuthv2 policy](/apigee/docs/api-platform/reference/policies/oauthv2-policy) returns a `302`\nredirect to the\nredirect URI with a `?code` query parameter containing the authorization code.\n\nIn some cases, you may want to change this behavior. For example, you may want to return a\n`200`\nresponse with structured JSON containing the code.\n\nOne way to accomplish this use case is to set the OAuthV2 policy's\n[GenerateResponse property](/apigee/docs/api-platform/reference/policies/oauthv2-policy#generateresponseelement) to `false`.\nUse the [ExtractVariable policy](/apigee/docs/api-platform/reference/policies/extract-variables-policy) to get the value of the authorization code from the variable\n`oauthv2authcode.{policy_name}.code`. Then, you can use the\n[AssignMessage policy](/apigee/docs/api-platform/reference/policies/assign-message-policy)\nto return the code in a JSON payload with a status of 200.\n\nAuditing app end user consent\n-----------------------------\n\nYou may be required to verify that an app end user authorized an app. You can use the Apigee\nAudit API to do so.\n\nOutbound OAuth sample\n---------------------\n\nSee the [outbound-oauth](https://github.com/apigee/api-platform-samples/tree/master/sample-proxies/outbound-oauth) sample\nin the Apigee api-platform-samples repository on GitHub. You can clone the sample, deploy it, and\nrun it. This sample uses the Microsoft Azure translator API to translate tweets. To do so, it\nmakes an outbound call to obtain an OAuth access token, and then caches the token using the API\nServices caching policies, reusing the cached token each time an outbound call is made. Also,\nincludes a demonstration browser app used to invoke the API proxy."]]