Cette page explique comment configurer un projet Google Cloud et configurer des comptes de service pour y accéder.
Configurer un projet Google Cloud
Suivez ces étapes pour configurer un projet Google Cloud. Notez que si vous ne prévoyez pas d'utiliser un CDN pour distribuer du contenu, il vous suffit d'attribuer le rôle Utilisateur d'assembleur vidéo (et non le rôle Administrateur d'assembleur vidéo) au compte de service.
- 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
- Utilisez l'outil
gcloud
pour tester votre environnement d'authentification. Vérifiez que la commande suivante génère une chaîne de texte sans erreur :gcloud auth application-default print-access-token
Activer le compte de service
- Dans votre terminal, définissez le projet actif pour les commandes gcloud. Remplacez YOUR_PROJECT_ID par votre ID de projet :
gcloud config set project YOUR_PROJECT_ID
- Activez le compte de service. Remplacez PATH_TO_YOUR_SERVICE_KEY par le chemin d'accès au fichier JSON que vous avez téléchargé sur votre ordinateur local.
gcloud auth activate-service-account --key-file PATH_TO_YOUR_SERVICE_KEY
Vous utiliserez ce compte de service pour autoriser l'accès à l'API Video Stitcher et l'appeler.
Créer un compte de service avec uniquement les autorisations nécessaires pour créer des sessions
Étant donné qu'un jeton OAuth sera transmis à une application cliente, créez un compte de service distinct ne disposant que des autorisations nécessaires pour créer une session. La fuite d'un jeton OAuth ne peut donc pas compromettre vos ressources, telles que les clés 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.