Ganti YOUR_SERVICE_ACCOUNT_EMAIL dengan email akun layanan Anda.
Ganti YOUR_AUDIENCE dengan nilai di kolom aud
yang dikirim oleh layanan panggilan.
Dalam kode penerapan API, impor Users:
importcom.google.api.server.spi.auth.common.User;
Di setiap metode API tempat Anda ingin memeriksa autentikasi yang tepat,
periksa User yang valid dan tampilkan pengecualian jika tidak ada, seperti
yang ditunjukkan dalam contoh definisi metode ini:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 UTC."],[[["\u003cp\u003eThis guide requires you to have already created a Google Cloud project and added API management to it.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication with a service account requires specific parameters in your \u003ccode\u003e@Api\u003c/code\u003e annotation, including \u003ccode\u003eauthenticators\u003c/code\u003e, \u003ccode\u003eissuers\u003c/code\u003e, and \u003ccode\u003eissuerAudiences\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEach API method can be configured to check for a valid \u003ccode\u003eUser\u003c/code\u003e, throwing an exception if the user is invalid for authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe API must be redeployed after you set up authentication for it to take effect, and anytime you add new clients.\u003c/p\u003e\n"]]],[],null,[]]