Questa pagina mostra come impostare un progetto Google Cloud e configurare gli account di servizio per accedere al progetto.
Configura un progetto Google Cloud
Segui questi passaggi per configurare un progetto Google Cloud. Tieni presente che, se non prevedi di utilizzare una CDN per distribuire contenuti, devi solo concedere il ruolo Utente stitching video (e non il ruolo Amministratore stitching video) all'account di servizio.
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Video Stitcher API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
Grant the Video Stitcher Admin role to the service account.
To grant the role, find the Select a role list, then select Video Stitcher Admin.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Video Stitcher API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
Grant the Video Stitcher Admin role to the service account.
To grant the role, find the Select a role list, then select Video Stitcher Admin.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again. - Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- Usa lo strumento
gcloud
per testare il tuo ambiente di autenticazione. Verifica che il seguente comando restituisca una stringa di testo senza errori:gcloud auth application-default print-access-token
Attiva l'account di servizio
- Nel terminale, imposta il progetto attivo per i comandi gcloud. Sostituisci YOUR_PROJECT_ID con l'ID progetto.
gcloud config set project YOUR_PROJECT_ID
- Attiva l'account di servizio. Sostituisci PATH_TO_YOUR_SERVICE_KEY con il percorso del file JSON che hai scaricato sulla tua macchina locale.
gcloud auth activate-service-account --key-file PATH_TO_YOUR_SERVICE_KEY
Utilizzerai questo account di servizio per autorizzare l'accesso e chiamare l'API Video Stitcher.
Crea un account di servizio con solo autorizzazioni per creare sessioni
Poiché un token OAuth verrà trasmesso a un'applicazione client, crea un account di servizio separato con autorizzazioni unicamente per creare una sessione. In questo modo, un token OAuth nascosto non può compromettere le tue risorse, ad esempio le chiavi CDN.
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
Grant the Video Stitcher User role to the service account.
To grant the role, find the Select a role list, then select Video Stitcher User.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.