승인 코드 부여 유형을 사용하는 경우 개발자 앱 등록 시 리디렉션 URI를 지정해야 합니다. 리디렉션 URI는 클라이언트 앱을 대신하여 승인 코드를 수신하도록 지정된 앱의 URI를 지정합니다. 클라이언트는 승인 코드 및 토큰을 요청할 때 이 URI를 Apigee에 보내며, redirect_uri 매개변수는 등록된 매개변수와 일치해야 합니다. OAuth 2.0 토큰 가져오기도 참조하세요.
/authorize 요청은 redirect_uri 매개변수에서 URI를 하나만 포함해야 합니다.
개발자 앱 UI에서 리디렉션 URI가 콜백 URL 필드에 지정된 URI 중 하나와 일치하면 요청이 성공합니다.
GenerateAuthCode 작업의 기본 반환 동작 변경
기본적으로 OAuthv2 정책의 GenerateAuthCode 작업은 승인 코드가 포함된 ?code 쿼리 매개변수가 있는 리디렉션 URL로 302 리디렉션을 반환합니다.
경우에 따라 이 동작을 변경해야 할 수 있습니다. 예를 들어 코드가 포함된 구조화된 JSON을 사용하여 200 응답을 반환해야 할 수 있습니다.
이 사용 사례를 달성하는 한 가지 방법은 OAuthV2 정책의 GenerateResponse 속성을 false로 설정하는 것입니다.
ExtractVariable 정책을 사용하여 oauthv2authcode.{policy_name}.code 변수에서 승인 코드 값을 가져옵니다. 그런 다음 AssignMessage 정책을 사용하여 상태가 200인 JSON 페이로드로 코드를 반환할 수 있습니다.
앱 최종 사용자 동의 감사
앱 최종 사용자가 앱을 승인했는지 확인해야 할 수 있습니다. Apigee Audit API를 사용하여 이를 수행할 수 있습니다.
아웃바운드 OAuth 샘플
GitHub의 Apigee api-platform-samples 저장소에 있는 outbound-oauth 샘플을 참조하세요. 샘플을 클론, 배포, 실행할 수 있습니다. 이 샘플은 Microsoft Azure Translator API를 사용하여 트윗을 변환합니다. 이를 위해 아웃바운드 호출을 수행하여 OAuth 액세스 토큰을 가져온 다음, API 서비스 캐싱 정책에 따라 토큰을 캐시합니다. 그러면 아웃바운드 호출이 수행될 때마다 캐시된 토큰이 재사용됩니다. 또한 API 프록시를 호출하는 데 사용되는 데모 브라우저 앱도 포함됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-19(UTC)"],[[["\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."]]