Generazione delle credenziali di autenticazione dell'API REST di Google Wallet
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Google Wallet offre un'API REST che ti consente di creare e gestire le tessere inviando richieste all'API Google Wallet tramite HTTP. Ciò è utile per chi vuole creare servizi lato server che funzionino con le tessere in modo programmatico.
Per utilizzare l'API REST di Google Wallet, devi abilitare l'API nella console Google Cloud, creare un account di servizio Google Cloud, quindi generare una chiave per l'account di servizio.
Quando crei tessere con l'API REST, la chiave dell'account di servizio utilizzata per firmare i tuoi passe oggetti codificati con token web JSON.
Per altre operazioni, come l'aggiornamento o l'eliminazione delle tessere, la chiave dell'account di servizio viene inviata con la richiesta per autenticarti come emittente della tessera.
1. Abilita l'API REST di Google Wallet
Per abilitare l'API REST di Google Wallet, segui questi passaggi:
- Se non hai ancora un account Google Cloud, vai alla console Google Cloud e segui i passaggi per registrare un nuovo account.
- Dal menu a discesa del progetto nella parte superiore della console, seleziona il progetto Google Cloud che vuoi utilizzare o creane uno nuovo.
- Vai alla pagina dei dettagli del prodotto API Google Wallet nel Marketplace della console Google Cloud.
- Fai clic sul pulsante "Attiva". Tra pochi istanti, l'API REST di Google Wallet sarà disponibile per il progetto Google Cloud selezionato.
2. Genera una chiave dell'account di servizio Google Cloud
Per autenticare le richieste all'API REST di Google Wallet, devi creare un account di servizio e generare una chiave dell'account di servizio seguendo questi passaggi:
- Vai alla pagina "Crea account di servizio" nella console Google Cloud.
- Inserisci i dettagli dell'account di servizio. Prendi nota dell'indirizzo email dell'account di servizio che appare sotto il campo "ID account di servizio". Ne avrai bisogno in seguito
quando utilizzerai l'account di servizio per autenticare le tue richieste all'API REST di Google Wallet.
- Fai clic sul pulsante "FINE". Non è necessario completare gli altri passaggi di creazione
dell'account di servizio.
- Fai clic sulla voce di menu "CHIAVE" nella parte superiore della pagina.
- Fai clic sul menu a discesa "AGGIUNGI CHIAVE", quindi su "Crea nuova chiave".
- Seleziona il tipo di chiave "JSON".
- Fai clic su "CREA" per creare e scaricare la chiave dell'account di servizio.
3. Autorizza il tuo account di servizio nella console Google Wallet
Per autenticare le tue richieste all'API REST di Google Wallet utilizzando una chiave dell'account di servizio, devi aggiungere l'indirizzo email del tuo account di servizio come utente al tuo account emittente. Per aggiungere il tuo account di servizio come utente:
- Vai alla pagina "Account di servizio" nella console Google Cloud.
- Copia l'indirizzo email dell'account di servizio che vuoi utilizzare per autenticare le tue richieste all'API Google Wallet.
- Vai alla console Google Pay & Wallet.
- Nel menu di navigazione a sinistra, fai clic su "Utenti".
- Fai clic su "Invita un utente".
- Inserisci l'indirizzo email del tuo account di servizio.
- Nel menu a discesa "Livello di accesso", seleziona "Sviluppatore".
- Fai clic sul pulsante "Invita".
Dopo aver aggiunto l'account di servizio, puoi utilizzare qualsiasi chiave dell'account di servizio generata per autenticare le richieste all'API REST di Google Wallet. Se utilizzi le chiavi degli account di servizio, tieni presente che si tratta di credenziali altamente sensibili che devono essere utilizzate solo in ambienti sicuri lato server.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-29 UTC.
[null,null,["Ultimo aggiornamento 2025-08-29 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 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."]]