Antes de começar

Nesta página, mostramos como configurar um projeto do Google Cloud e configurar contas de serviço para acessar o projeto.

Configure um projeto do Google Cloud

Siga estas etapas para configurar um projeto do Google Cloud: Se você não planeja usar uma CDN para distribuir conteúdo, só é necessário conceder o papel de Usuário de editor de vídeo (e não o papel de Administrador de editor de vídeo) à conta de serviço.

  1. Faça login na sua conta do Google Cloud. Se você começou a usar o Google Cloud agora, crie uma conta para avaliar o desempenho de nossos produtos em situações reais. Clientes novos também recebem US$ 300 em créditos para executar, testar e implantar cargas de trabalho.
  2. No console do Google Cloud, na página do seletor de projetos, selecione ou crie um projeto do Google Cloud.

    Acessar o seletor de projetos

  3. Verifique se a cobrança está ativada para o seu projeto do Google Cloud.

  4. Ative a Video Stitcher API.

    Ative a API

  5. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. 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.

    4. Click Create and continue.
    5. 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.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  6. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  7. Defina a variável de ambiente GOOGLE_APPLICATION_CREDENTIALS como o caminho do arquivo JSON que contém suas credenciais. Essa variável só se aplica à sessão de shell atual. Assim, se você abrir uma nova sessão, precisará definir a variável novamente.

  8. No console do Google Cloud, na página do seletor de projetos, selecione ou crie um projeto do Google Cloud.

    Acessar o seletor de projetos

  9. Verifique se a cobrança está ativada para o seu projeto do Google Cloud.

  10. Ative a Video Stitcher API.

    Ative a API

  11. Create a service account:

    1. In the Google Cloud console, go to the Create service account page.

      Go to Create service account
    2. Select your project.
    3. 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.

    4. Click Create and continue.
    5. 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.

    6. Click Continue.
    7. Click Done to finish creating the service account.

      Do not close your browser window. You will use it in the next step.

  12. Create a service account key:

    1. In the Google Cloud console, click the email address for the service account that you created.
    2. Click Keys.
    3. Click Add key, and then click Create new key.
    4. Click Create. A JSON key file is downloaded to your computer.
    5. Click Close.
  13. Defina a variável de ambiente GOOGLE_APPLICATION_CREDENTIALS como o caminho do arquivo JSON que contém suas credenciais. Essa variável só se aplica à sessão de shell atual. Assim, se você abrir uma nova sessão, precisará definir a variável novamente.

  14. Instale a CLI do Google Cloud.
  15. Para inicializar a CLI gcloud, execute o seguinte comando:

    gcloud init
  16. Use a ferramenta gcloud para testar o ambiente de autenticação. Verifique se o comando a seguir gera uma string de texto sem erros:
    gcloud auth application-default print-access-token

Ativar a conta de serviço

  1. No terminal, defina o projeto ativo para comandos gcloud. Substitua YOUR_PROJECT_ID pelo ID do projeto.
    gcloud config set project YOUR_PROJECT_ID
    
  2. Ative a conta de serviço. Substitua PATH_TO_YOUR_SERVICE_KEY pelo caminho do arquivo JSON que você salvou na máquina local.
    gcloud auth activate-service-account --key-file PATH_TO_YOUR_SERVICE_KEY
    

Você vai usar essa conta de serviço para autorizar o acesso e chamar a API Video Stitcher.

Criar uma conta de serviço somente com permissões para criar sessões

Como um token OAuth será transmitido para um aplicativo cliente, crie uma conta de serviço separada somente com permissões para criar uma sessão. Assim, um token OAuth vazado não poderá comprometer seus recursos, como chaves de CDN.

Create a service account:

  1. In the Google Cloud console, go to the Create service account page.

    Go to Create service account
  2. Select your project.
  3. 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.

  4. Click Create and continue.
  5. 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.

  6. Click Continue.
  7. 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:

  1. In the Google Cloud console, click the email address for the service account that you created.
  2. Click Keys.
  3. Click Add key, and then click Create new key.
  4. Click Create. A JSON key file is downloaded to your computer.
  5. Click Close.