در حال ایجاد اعتبارنامه احراز هویت Google Wallet REST API
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Google Wallet یک API REST ارائه میکند که به شما امکان میدهد با ارسال درخواستها به API Google Wallet از طریق HTTP، مجوز ایجاد و مدیریت کنید. این برای کسانی که می خواهند سرویس های سمت سرور بسازند تا به صورت برنامه نویسی با آنها کار کنند مفید است.
برای استفاده از Google Wallet REST API، باید API را در کنسول Google Cloud فعال کنید، یک حساب سرویس Google Cloud ایجاد کنید، سپس یک کلید برای حساب سرویس ایجاد کنید.
وقتی با REST API مجوز ایجاد میکنید، کلید حساب سرویس برای امضای اشیاء عبور رمزگذاریشده با رمز وب JSON شما استفاده میشود.
برای سایر عملیاتها، مانند بهروزرسانی یا حذف مجوزها، کلید حساب سرویس همراه با درخواست احراز هویت شما بهعنوان صادرکننده مجوز ارسال میشود.
1. Google Wallet REST API را فعال کنید
برای فعال کردن Google Wallet REST API، موارد زیر را انجام دهید:
- اگر قبلاً یک حساب Google Cloud ندارید، به کنسول Google Cloud بروید و مراحل ثبت نام برای یک حساب جدید را دنبال کنید.
- از منوی کشویی پروژه در بالای کنسول، پروژه Google Cloud را که میخواهید استفاده کنید انتخاب کنید یا یک پروژه جدید ایجاد کنید.
- به صفحه جزئیات محصول Google Wallet API در بازار Google Cloud کنسول بروید.
- روی دکمه "فعال کردن" کلیک کنید. چند لحظه دیگر، Google Wallet REST API برای پروژه انتخابی Google Cloud در دسترس خواهد بود.
2. یک کلید حساب سرویس Google Cloud ایجاد کنید
برای احراز هویت درخواستها به Google Wallet REST API، باید یک حساب سرویس ایجاد کنید و یک کلید حساب سرویس را با انجام کارهای زیر ایجاد کنید:
- به صفحه «ایجاد حساب سرویس» در کنسول Google Cloud بروید.
- مشخصات حساب سرویس را وارد کنید. به آدرس ایمیل حساب سرویس که در زیر قسمت «شناسه حساب سرویس» ظاهر میشود، توجه کنید. بعداً وقتی از حساب سرویس برای تأیید اعتبار درخواستهای خود در Google Wallet REST API استفاده میکنید، به این نیاز خواهید داشت.
- روی دکمه "انجام شد" کلیک کنید. نیازی به تکمیل سایر مراحل ایجاد حساب کاربری نیست.
- روی آیتم منوی "KEYS" در بالای صفحه کلیک کنید.
- روی منوی کشویی «ADD KEY» کلیک کنید، سپس روی «ایجاد کلید جدید» کلیک کنید.
- نوع کلید "JSON" را انتخاب کنید.
- برای ایجاد و دانلود کلید حساب سرویس، روی «ایجاد» کلیک کنید.
3. حساب سرویس خود را در کنسول Google Wallet مجاز کنید
برای احراز هویت درخواستهای خود به Google Wallet REST API با استفاده از کلید حساب سرویس، باید آدرس ایمیل حساب سرویس خود را به عنوان کاربر به حساب صادرکننده خود اضافه کنید. برای افزودن حساب کاربری خود به عنوان کاربر، موارد زیر را انجام دهید:
- به صفحه «حسابهای خدمات» در کنسول Google Cloud بروید.
- آدرس ایمیل حساب سرویسی را که میخواهید برای احراز هویت درخواستهای خود استفاده کنید، در Google Wallet API کپی کنید.
- به کنسول Google Pay & Wallet بروید.
- در سمت چپ، روی «کاربران» کلیک کنید.
- روی "دعوت یک کاربر" کلیک کنید.
- آدرس ایمیل حساب سرویس خود را وارد کنید.
- در کشویی «سطح دسترسی»، «توسعهدهنده» را انتخاب کنید.
- روی دکمه "دعوت" کلیک کنید.
هنگامی که حساب سرویس شما اضافه شد، می توانید از هر کلید حساب سرویس ایجاد شده برای آن برای تأیید اعتبار درخواست ها به Google Wallet REST API استفاده کنید. هنگام استفاده از کلیدهای حساب سرویس، به خاطر داشته باشید که اینها اعتبارنامه های بسیار حساسی هستند که فقط باید در محیط های امن و سمت سرور استفاده شوند.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eGoogle Wallet's REST API enables programmatic management of passes through HTTP requests, ideal for server-side integrations.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize the API, you must enable it in the Google Cloud console, create a service account, and generate a key for authentication.\u003c/p\u003e\n"],["\u003cp\u003eThis service account key is crucial for signing Pass Objects during creation and authenticating other pass operations like updates and deletions.\u003c/p\u003e\n"],["\u003cp\u003eYou must add your service account email as a user in the Google Pay & Wallet console to grant API access.\u003c/p\u003e\n"]]],["The Google Wallet REST API allows programmatic pass management via HTTP requests. To use it, enable the API in the Google Cloud console, create a service account, and generate a JSON key. This key is used to sign JSON Web Token-encoded Pass Objects for creation and authenticates requests for updates or deletions. Finally, authorize the service account by adding its email as a 'Developer' user in the Google Pay & Wallet console. This process enables secure, server-side interaction with the Google Wallet.\n"],null,["# Generating Google Wallet REST API authentication credentials\n\nGoogle Wallet offers a REST API that lets you create and manage passes by\nsending requests to the Google Wallet API over HTTP. This is useful for those who\nwant to build server-side services to work with passes programmatically.\n\nTo use the Google Wallet REST API, you must enable the API in the Google Cloud console,\ncreate a Google Cloud service account, then generate a key for the service account.\n\nWhen you create passes with the REST API, the service account key used to sign your\nJSON Web Token-encoded Passes Objects.\n\nFor other operations, such as updating or deleting passes, the service account key\nis sent with the request to authenticate you as the Pass Issuer.\n\n1. Enable the Google Wallet REST API\n------------------------------------\n\nTo enable the Google Wallet REST API, do the following:\n\n1. If you don't already have a Google Cloud account, go to the [Google Cloud console](https://console.cloud.google.com) and follow the steps to register for a new account.\n2. From the project drop-down menu at the top of the console, select the Google Cloud project you want to use, or create a new one.\n3. Go to the [Google Wallet API product details page](https://console.cloud.google.com/apis/library/walletobjects.googleapis.com) in the Google Cloud console Marketplace.\n4. Click the 'Enable' button. In a few moments, the Google Wallet REST API will be available for the selected Google Cloud project.\n\n2. Generate a Google Cloud service account key\n----------------------------------------------\n\nTo authenticate requests to the Google Wallet REST API, you'll need to create a\nservice account, and generate a service account key by doing the following:\n\n1. Go to the ['Create service account' page](https://console.cloud.google.com/iam-admin/serviceaccounts/create) in the Google Cloud console.\n2. Fill in the service account details. Note the email address for the service account that appears below the 'Service account ID' field. You will need this later when you use the service account to authenticate your requests to the Google Wallet REST API.\n3. Click the 'DONE' button. There is no need to complete the other service account creation steps.\n4. Click the 'KEYS' menu item at the top of the page.\n5. Click the 'ADD KEY' drop-down menu, then click 'Create new key'.\n6. Select key type 'JSON'.\n7. Click 'CREATE' to create and download the service account key.\n\n3. Authorize your service account in the Google Wallet console\n--------------------------------------------------------------\n\nTo authenticate your requests to the Google Wallet REST API using a service account\nkey, you must add the email address of your service account as a user to your\nIssuer account. To add your service account as a user, do the following:\n\n1. Go to the ['Service accounts'](https://console.cloud.google.com/iam-admin/serviceaccounts) page in the Google Cloud console.\n2. Copy the email address of the service account you want to use to authenticate your requests to the Google Wallet API.\n3. Go to the [Google Pay \\& Wallet console](https://pay.google.com/business/console/).\n4. In the left nav, click 'Users'.\n5. Click 'Invite a user'.\n6. Input the email address of your service account.\n7. In the 'Access level' drop-down, select 'Developer'.\n8. Click the 'Invite' button.\n\nOnce your service account is added, you can use any service account keys generated\nfor it to authenticate requests to the Google Wallet REST API. When using service\naccount keys, keep in mind that these are highly sensitive credentials that\nshould only be used in secure, server-side environments."]]