액세스 토큰을 사용하여 사용자를 인증할 수 있습니다. 액세스 토큰은 이메일 발신자가 제공하고 확인합니다. 발신자는 토큰을 사용하여 AMP 이메일에 액세스할 수 있는 사용자만 이메일에 포함된 요청을 할 수 있도록 합니다. 액세스 토큰은 암호화로 보호되어야 하며 시간 및 범위가 제한되어야 합니다. 요청의 URL 내에 포함되어 있습니다.
다음 예에서는 로그인한 사용자가 계정에 메모를 추가하고 나중에 볼 수 있는 가상의 메모 작성 서비스를 고려합니다. 서비스는 사용자가 이전에 작성한 메모 목록이 포함된 이메일을 사용자 jane@example.com에게 보내려고 합니다. 현재 사용자의 메모 목록은 엔드포인트 https://example.com/personal-notes에서 JSON 형식으로 확인할 수 있습니다.
이메일을 보내기 전에 서비스는 jane@example.com: A3a4roX9x용으로 암호화 방식으로 안전한 사용 빈도가 제한된 액세스 토큰을 생성합니다. 액세스 토큰은 URL 쿼리 내의 필드 이름 exampletoken에 포함됩니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-03-24(UTC)"],[],[],null,["# Authenticating requests in AMP for Email\n\nDynamic personalized email content often requires authenticating the user.\nHowever, to protect user data all HTTP requests made from inside AMP emails\nwithin Gmail are proxied and stripped of cookies.\n\nTo authenticate requests made from AMP emails, you may use\n[access tokens](#access_tokens).\n\nAccess tokens\n-------------\n\nYou can use access tokens to authenticate the user. Access tokens are\nsupplied and checked by the email sender. The sender uses the tokens to ensure\nthat only those with access to the AMP email can make the requests contained\nwithin that email. Access tokens must be cryptographically secure and time- and\nscope-limited. They are included within the URL of the request.\n\nThis example demonstrates using `\u003camp-list\u003e` to display authenticated data: \n\n \u003camp-list src=\"https://example.com/endpoint?token=REPLACE_WITH_YOUR_ACCESS_TOKEN\"\n height=\"300\"\u003e\n \u003ctemplate type=\"amp-mustache\"\u003e\n ...\n \u003c/template\u003e\n \u003c/amp-list\u003e\n\nSimilarly when using `\u003camp-form\u003e`, place your access token in the `action-xhr`\nURL. \n\n \u003cform action-xhr=\"https://example.com/endpoint?token=REPLACE_WITH_YOUR_ACCESS_TOKEN\" method=\"post\"\u003e\n \u003cinput type=\"text\" name=\"data\"\u003e\n \u003cinput type=\"submit\" value=\"Send\"\u003e\n \u003c/form\u003e\n\n| **Note:** Email clients typically strip the AMP mime part on reply / forward. \n|\n| Also, Gmail only considers an AMP part to be useable for 30 days after it is received so the lifetime of your access token should be set to 31 days.\n\n### Example\n\nThe following example considers a hypothetical note-taking service that lets\nlogged-in users to add notes to their account and view them later. The service\nwants to send an email to a user, `jane@example.com`, that includes a list of\nnotes they previously took. The list of the current user's notes is available\nat the endpoint `https://example.com/personal-notes` in JSON format.\n\nBefore sending the email, the service generates a cryptographically secure\nlimited-use access token for `jane@example.com: A3a4roX9x`. The access token is\nincluded in the field name `exampletoken` inside the URL query: \n\n \u003camp-list src=\"https://example.com/personal-notes?exampletoken=A3a4roX9x\" height=\"300\"\u003e\n \u003ctemplate type=\"amp-mustache\"\u003e\n \u003cp\u003e{{note}}\u003c/p\u003e\n \u003c/template\u003e\n \u003c/amp-list\u003e\n\nThe endpoint `https://example.com/personal-notes` is responsible for validating\nthe `exampletoken` parameter and finding the user associated with the token.\n\nFor more information, see\n[Limited use access tokens](/workspace/gmail/markup/actions/limited-use-access-tokens).\n| **Note:** A conventional web application could query the user notes endpoint with an XMLHttpRequest (XHR), and a cookie could provide the endpoint with the user's identity. In AMP for email, however, this approach doesn't work because all HTTP requests are anonymized in Gmail AMP emails. Instead, AMP must identify the user in the URL itself."]]