Membuat kredensial autentikasi REST API Google Wallet
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Google Wallet menawarkan REST API yang memungkinkan Anda membuat dan mengelola kartu dengan
mengirimkan permintaan ke Google Wallet API melalui HTTP. Hal ini berguna bagi mereka yang ingin mem-build layanan sisi server agar berfungsi dengan kartu secara terprogram.
Untuk menggunakan Google Wallet REST API, Anda harus mengaktifkan API di Konsol Google Cloud, membuat akun layanan Google Cloud, lalu membuat kunci untuk akun layanan.
Saat Anda membuat kartu dengan REST API, kunci akun layanan yang digunakan untuk menandatangani Objek Kartu yang berenkode Token Web JSON.
Untuk operasi lain, seperti memperbarui atau menghapus kartu, kunci akun layanan akan dikirim dengan permintaan untuk mengautentikasi Anda sebagai Penerbit Kartu.
1. Mengaktifkan Google Wallet REST API
Untuk mengaktifkan Google Wallet REST API, lakukan hal berikut:
- Jika belum memiliki akun Google Cloud, buka Google Cloud Console dan ikuti langkah-langkah untuk mendaftar akun baru.
- Dari menu drop-down project di bagian atas konsol, pilih project Google Cloud yang ingin Anda gunakan, atau buat yang baru.
- Buka halaman detail produk Google Wallet API
di Marketplace Konsol Google Cloud.
- Klik tombol 'Enable'. Dalam beberapa saat, Google Wallet REST API akan tersedia untuk project Google Cloud yang dipilih.
2. Membuat kunci akun layanan Google Cloud
Untuk mengautentikasi permintaan ke Google Wallet REST API, Anda harus membuat akun layanan dan membuat kunci akun layanan dengan melakukan hal berikut:
- Buka halaman'Create service account' di Konsol Google Cloud.
- Isi detail akun layanan. Catat alamat email untuk akun layanan yang muncul di bawah kolom 'ID akun layanan'. Anda akan memerlukannya nanti saat menggunakan akun layanan untuk mengautentikasi permintaan ke REST API Google Wallet.
- Klik tombol 'SELESAI'. Tidak perlu menyelesaikan langkah-langkah pembuatan akun layanan lainnya.
- Klik item menu 'KUNCI' di bagian atas halaman.
- Klik menu drop-down 'ADD KEY', lalu klik 'Create new key'.
- Pilih jenis kunci 'JSON'.
- Klik 'CREATE' untuk membuat dan mendownload kunci akun layanan.
3. Memberi otorisasi pada akun layanan di konsol Google Wallet
Untuk mengautentikasi permintaan ke Google Wallet REST API menggunakan kunci akun layanan, Anda harus menambahkan alamat email akun layanan sebagai pengguna ke Akun penerbit Anda. Untuk menambahkan akun layanan sebagai pengguna, lakukan hal berikut:
- Buka halaman 'Service accounts' di Konsol Google Cloud.
- Salin alamat email akun layanan yang ingin Anda gunakan untuk mengautentikasi permintaan ke Google Wallet API.
- Buka konsol Google Pay & Wallet.
- Di navigasi sebelah kiri, klik 'Pengguna'.
- Klik 'Undang pengguna'.
- Masukkan alamat email akun layanan Anda.
- Di drop-down 'Tingkat akses', pilih 'Developer'.
- Klik tombol 'Undang'.
Setelah akun layanan ditambahkan, Anda dapat menggunakan kunci akun layanan apa pun yang dibuat untuk mengautentikasi permintaan ke Google Wallet REST API. Saat menggunakan kunci akun layanan, perlu diingat bahwa kunci ini adalah kredensial yang sangat sensitif yang hanya boleh digunakan di lingkungan sisi server yang aman.
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-09-03 UTC.
[null,null,["Terakhir diperbarui pada 2025-09-03 UTC."],[[["\u003cp\u003eGoogle Wallet's REST API enables programmatic management of passes via HTTP requests.\u003c/p\u003e\n"],["\u003cp\u003eTo use the API, you must enable it in Google Cloud Console, create a service account, and generate a key.\u003c/p\u003e\n"],["\u003cp\u003eThe service account key is used for authentication when creating, updating, or deleting passes.\u003c/p\u003e\n"],["\u003cp\u003eEnsure your service account is authorized as a 'Developer' in the Google Pay & Wallet console to authenticate requests.\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."]]