L'API Search Ads 360 Reporting precedente è stata ritirata. Ora puoi creare i report utilizzando la nuova API Search Ads 360 Reporting.
Tieni presente che i metodi get e getByCustomerId nell'API Search Ads 360 Conversion verranno ritirati nel terzo trimestre del 2025. Per continuare ad accedere ai dati sulle conversioni, devi creare un report utilizzando la risorsa conversion con la nuova API Search Ads 360 Reporting. Scopri di più qui.
Le restanti funzioni dell'API Search Ads 360 Conversion continueranno a essere supportate.
Configura l'autorizzazione
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
L'API Search Ads 360 richiede che tutte le richieste specifichino un token di accesso OAuth 2.0 per l'autenticazione. Puoi seguire qualsiasi flusso di lavoro di autenticazione OAuth 2.0 standard per generare il token e passarlo all'API Search Ads 360. Consigliamo il flusso di lavoro descritto di seguito perché è adatto per caricamenti delle conversioni e download dei report completamente automatici.
Per alternative al flusso di lavoro descritto di seguito, consulta Utilizzo di OAuth 2.0 per le applicazioni installate o
Utilizzo di OAuth 2.0 per le applicazioni da server a server. Se utilizzi un flusso di lavoro alternativo,
specifica il seguente valore come parametro scope
quando richiedi un codice di autorizzazione OAuth
2.0:
https://www.googleapis.com/auth/doubleclicksearch
Se segui il percorso server-to-server, aggiungi l'account di servizio come utente di Search Ads 360.
Flusso di lavoro di autorizzazione consigliato
- Vai alla console API di Google e seleziona il tuo progetto.
Se non hai ancora creato un progetto della console API di Google e le credenziali OAuth, segui
le istruzioni riportate in Creare un progetto della console API di Google e le credenziali OAuth per il client.
Per trovare l'ID client OAuth e il client secret del tuo progetto:
- Apri la pagina Credenziali.
- Nella colonna Nome, fai clic sul nome del client OAuth.
- L'ID client e il client secret sono elencati nella pagina.
- Apri un browser web e accedi a Google
con un Account Google che disponga dell'autorizzazione per accedere ai dati in Search Ads 360.
Si tratta dell'Account Google che il client API utilizzerà per autenticarsi in Search Ads 360.
Se il proprietario dell'Account Google lascia la tua azienda e rimuovi l'accesso a Search Ads 360
dall'account, dovrai ripetere questo flusso di lavoro di autorizzazione e specificare un
Account Google diverso.
- Ottieni un token di aggiornamento richiamando lo script dell'utilità di Search Ads 360 come segue:
sa360Api.py --login
Lo script illustra la procedura di utilizzo dell'ID client e del secret OAuth per
ottenere un token di aggiornamento. Il token di aggiornamento è valido solo per l'Account Google a cui hai eseguito l'accesso nel passaggio precedente.
Nell'ambito di questa procedura, lo script genera un URL e ti invita a
visitarlo in un browser web.
-
Quando il browser ti chiede di consentire l'accesso del client OAuth ai dati di Search Ads 360,
assicurati che venga visualizzato l'Account Google a cui hai eseguito l'accesso in precedenza. Se hai eseguito l'accesso a più Account Google, potresti visualizzare un account diverso.
Al termine del processo, lo script sa360Api.py
genera una stringa delimitata da virgole. Il primo valore è l'ID cliente che hai fornito, il secondo è il client secret che hai fornito e il terzo è il token di aggiornamento. Nell'output dell'esempio seguente, il token di aggiornamento è in testo in grassetto:
123456789123.apps.googleusercontent.com,ABCDEFGHIJKLMNOPQR_abcdef,1/HIJklM01OPQR23NOP456rst890uvw
- Memorizza l'ID cliente, il client secret e il token di aggiornamento in un database di backend o in un'altra posizione sicura accessibile alla tua applicazione.
Conserva l'intera stringa delimitata da virgole in una posizione comoda se prevedi di utilizzare
sa360Api.py
per inviare richieste JSON di esempio all'API Search Ads 360. Dovrai passare l'intera stringa come parametro ogni volta che richiami lo script.
- Aggiungi alla tua applicazione il codice che esegue le seguenti operazioni:
- Utilizza l'ID client, il client secret e il token di aggiornamento per ottenere un nuovo token di accesso OAuth 2.0.
- Invia richieste all'API Search Ads 360 utilizzando il token di accesso aggiornato.
Se utilizzi le librerie client, la sezione successiva, Configura l'applicazione, descrive come aggiungere questo codice di autorizzazione alla tua applicazione.
Se non utilizzi una delle librerie client, consulta l'articolo sull'utilizzo di OAuth 2.0 per le applicazioni installate per suggerimenti su come ottenere un nuovo token di accesso.
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 2024-11-07 UTC.
[null,null,["Ultimo aggiornamento 2024-11-07 UTC."],[[["\u003cp\u003eThe Search Ads 360 API requires OAuth 2.0 access tokens for authentication, obtainable through standard OAuth 2.0 workflows or the recommended workflow outlined in the document.\u003c/p\u003e\n"],["\u003cp\u003eThe recommended workflow involves obtaining a refresh token using the provided utility script and storing it securely along with the client ID and secret.\u003c/p\u003e\n"],["\u003cp\u003eApplications should be designed to use the stored credentials to obtain fresh access tokens for API requests, as detailed in the "Set Up Your Application" section or relevant OAuth 2.0 documentation.\u003c/p\u003e\n"],["\u003cp\u003eAlternative workflows for installed or server-to-server applications are available with specific scope requirements and user management considerations.\u003c/p\u003e\n"]]],["The Search Ads 360 API requires OAuth 2.0 access tokens for authentication. The recommended workflow involves creating a Google API Console project and obtaining OAuth credentials. Users sign into a Google Account with Search Ads 360 access, then use the `sa360Api.py` script to generate a refresh token. The script outputs client ID, client secret, and refresh token. Store these securely, and use them in your application to obtain a fresh OAuth access token for API requests.\n"],null,["# Set Up Authorization\n\nThe Search Ads 360 API requires all requests to specify an [OAuth 2.0](/accounts/docs/OAuth2)\naccess token for authentication. You can follow any standard OAuth 2.0 authentication workflow\nto generate the token and pass it to the Search Ads 360 API. We recommend the workflow described\nbelow because it is suitable for fully automated conversion uploads and report downloads.\n\n\nFor alternatives to the workflow described below, see [Using\nOAuth 2.0 for Installed Applications](https://developers.google.com/accounts/docs/OAuth2InstalledApp) or\n[Using OAuth 2.0 for Server to Server Applications](https://developers.google.com/identity/protocols/OAuth2ServiceAccount). If you use an alternate workflow,\nspecify the following value as the `scope` parameter when you request an OAuth\n2.0 authorization code: \n\n`https://www.googleapis.com/auth/doubleclicksearch`\n\nIf you follow the server to server route, add the service account as a Search Ads 360 user.\n\nRecommended authorization workflow\n----------------------------------\n\n1. Go to the [Google API Console](https://console.cloud.google.com/) and select your project.\n\n\n If you haven't already created a Google API Console project and OAuth credentials, follow\n the instructions in [Create a Google API\n Console project and OAuth credentials for your client](/search-ads/v2/prereqs#project).\n\n To find your project's OAuth client ID and secret, do the following:\n 1. Open the [Credentials page](https://console.cloud.google.com/apis/credentials).\n 2. In the **Name** column, click the name of your OAuth client.\n 3. The client ID and secret are listed on the page.\n2. Open a web browser and [sign into Google](https://accounts.google.com/ServiceLogin)with a Google Account that [has\n permission to access data](/search-ads/v2/prereqs#permissions) in Search Ads 360.\n\n This is the Google Account your API client will use to authenticate with Search Ads 360.\n If the Google Account holder leaves your company and you remove Search Ads 360 access\n from the account, you will need to repeat this authorization workflow and specify a\n different Google Account.\n3. Obtain a refresh token by invoking the [Search Ads 360 utility script](/search-ads/v2/prereqs#ds3py) as follows:\n\n\n `sa360Api.py --login`\n\n\n The script takes you through the process of using the Oauth client ID and secret to\n obtain a refresh token. The refresh token is valid only for the Google Account you signed\n into during the previous step.\n\n As part of this process, the script generates a URL and instructs you to\n visit the URL in a web browser.\n4. When the browser asks you to allow OAuth client access to Search Ads 360 data,\n make sure the Google Account you signed into earlier appears. (If you're signed into multiple\n Google Accounts, you might be presented with a different account.)\n\n\n At the end of the process, the `sa360Api.py` script outputs a comma-delimited\n string. The first value is the client ID you provided, the second value is the client\n secret you provided, and the third value is the refresh token. In the following example\n output, the refresh token is in **bold text** : \n\n `123456789123.apps.googleusercontent.com,ABCDEFGHIJKLMNOPQR_abcdef,`**1/HIJklM01OPQR23NOP456rst890uvw**\n5. Store the client ID, client secret, and refresh token in a backend database or other secure location that's accessible to your application.\n Keep the entire comma-delimited string in a convenient location if you plan to use\n `sa360Api.py` to send sample JSON requests to the Search Ads 360 API. You'll pass the\n entire string as a parameter each time you invoke the script.\n\n6. Add code to your application that does the following:\n 1. Use the client ID, client secret, and refresh token to obtain a fresh OAuth 2.0 access token.\n 2. Send requests to the Search Ads 360 API using the fresh access token.\n\n\n If you're using the client libraries, the next section, [Set Up Your Application](/search-ads/v2/configure),\n describes how to add this authorization code to your application.\n\n\n If you're not using one of the client libraries, see [Using OAuth 2.0 for Installed Applications](https://developers.google.com/accounts/docs/OAuth2InstalledApp) for\n suggestions on obtaining a fresh access token."]]