Генерация учетных данных для аутентификации REST API Google Кошелька
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Google Кошелек предлагает REST API, который позволяет создавать пропуска и управлять ими, отправляя запросы к API Google Кошелька через HTTP. Это полезно для тех, кто хочет создать серверные сервисы для программной работы с проходами.
Чтобы использовать REST API Google Кошелька, необходимо включить API в консоли Google Cloud, создать учетную запись службы Google Cloud, а затем сгенерировать ключ для учетной записи службы.
Когда вы создаете проходы с помощью REST API, ключ учетной записи службы используется для подписи ваших объектов Passes, закодированных веб-токеном JSON.
Для других операций, таких как обновление или удаление пропусков, ключ служебной учетной записи отправляется с запросом на аутентификацию вас как эмитента пропусков.
1. Включите REST API Google Кошелька.
Чтобы включить REST API Google Кошелька, выполните следующие действия:
- Если у вас еще нет учетной записи Google Cloud, перейдите в консоль Google Cloud и следуйте инструкциям по регистрации новой учетной записи.
- В раскрывающемся меню проекта в верхней части консоли выберите проект Google Cloud, который вы хотите использовать, или создайте новый.
- Перейдите на страницу сведений о продукте API Google Кошелька в магазине консоли Google Cloud.
- Нажмите кнопку «Включить». Через несколько минут REST API Google Кошелька станет доступен для выбранного проекта Google Cloud.
2. Создайте ключ учетной записи службы Google Cloud.
Для аутентификации запросов к REST API Google Кошелька вам необходимо создать учетную запись службы и сгенерировать ключ учетной записи службы, выполнив следующие действия:
- Перейдите на страницу «Создать сервисный аккаунт» в консоли Google Cloud.
- Заполните данные учетной записи службы. Обратите внимание на адрес электронной почты учетной записи службы, который отображается под полем «Идентификатор учетной записи службы». Это понадобится вам позже, когда вы будете использовать учетную запись службы для аутентификации своих запросов к REST API Google Кошелька.
- Нажмите кнопку «ГОТОВО». Нет необходимости выполнять другие шаги по созданию учетной записи службы.
- Нажмите пункт меню «КЛЮЧИ» вверху страницы.
- Откройте раскрывающееся меню «ДОБАВИТЬ КЛЮЧ», затем нажмите «Создать новый ключ».
- Выберите тип ключа «JSON».
- Нажмите «СОЗДАТЬ», чтобы создать и загрузить ключ сервисной учетной записи.
3. Авторизуйте свой сервисный аккаунт в консоли Google Кошелька.
Чтобы аутентифицировать ваши запросы к REST API Google Кошелька с помощью ключа учетной записи службы, вы должны добавить адрес электронной почты своей учетной записи службы в качестве пользователя в свою учетную запись эмитента. Чтобы добавить свою учетную запись службы в качестве пользователя, выполните следующие действия:
- Перейдите на страницу «Служебные аккаунты» в консоли Google Cloud.
- Скопируйте адрес электронной почты учетной записи службы, которую вы хотите использовать для аутентификации ваших запросов к API Google Кошелька.
- Перейдите в консоль Google Pay & Wallet .
- В левой панели навигации нажмите «Пользователи».
- Нажмите «Пригласить пользователя».
- Введите адрес электронной почты вашей учетной записи службы.
- В раскрывающемся списке «Уровень доступа» выберите «Разработчик».
- Нажмите кнопку «Пригласить».
После добавления учетной записи службы вы можете использовать любые ключи учетной записи службы, сгенерированные для нее, для аутентификации запросов к REST API Google Кошелька. При использовании ключей служебной учетной записи имейте в виду, что это очень конфиденциальные учетные данные, которые следует использовать только в безопасных серверных средах.
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-09-04 UTC.
[[["Прост для понимания","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-09-04 UTC."],[[["\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 Google Cloud service account, and generate a key for authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe service account key is crucial for signing JSON Web Token-encoded Passes Objects during pass creation and authenticating other operations like updates or deletions.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the API, authorize your service account by adding its email address as a Developer user in the Google Pay & Wallet console.\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."]]