Skip to Content

Authorize SAP Build Process Automation with Google Authorization SDK

Authorize SAP Build Process Automation to automate Google Applications with Google Authorization SDK
You will learn
  • How to use the authorization mechanisms supported by the Google Authorization SDK
celineaudinsapCéline AudinJanuary 18, 2023
Created by
December 16, 2022


SAP Build Process Automation enables users to automate Google Workspace products such as Gmail, Google Drive, Google Sheets, Google Docs, Google Calendar and other services such as Google Cloud Storage, Document AI and Vision AI. In order to automate Google workspace products, you have to be authorized. There are three authorization mechanisms that Google supports:

  • Service Account
  • oAuth
  • Workflow Identity Federation

SAP Build Process Automation supports Service Account and oAuth. In this tutorial, you will authorize using Service Account.

What is a Service Account ?

Service account differs from user accounts and it will be used by a software application to make authorized API calls. The service account can also be authorized to access data on behalf of users in a domain without their consent by enabling Domain-wide delegation. The service accounts should be created and configured through Google Cloud Console before using the activity in SAP Build Process Automation. Refer to pre-requisites to Setup Service Account.

  • Step 1

    Before you can authorize Google applications, you will need to create an automation.

    1. From the Lobby, choose Create.

    2. In the pop-up, select Build an Automated Process.

      Automated Process
    3. Select Task Automation.

      Task Automation
    4. In the Create Task Automation window, enter the name: Google Suite and as a description: A demo to automate Google Applications using Google SDK.

    5. Choose Create.

      Automated Process

      You will be asked to configure your agent version.

    6. Select the agent version that is registered on your system.

      Configure Agent Version

      A pop-up window will prompt you to create an automation.

    7. In the name field enter Google Authorization.

    8. In the description field enter An automation to authorize Google.

    9. Choose Create.

      Create automation

      A new automation named Google Authorization will be successfully created. You will be navigated to the automation editor where you can start building your automation.

      Create automation
  • Step 2

    Environment Variables allow you to reuse certain information for a given environment. You use environment variables to pass parameters to automations. In this case, you will need to maintain two environment variables that will contain the file full path of the service account key file as well as the user email used in the automation.

    1. Select Settings.

    2. In the Project Properties window, select Environment Variables, then + Create.

      Create Environment Variable
    3. In the create an environment variable screen:

      • Under Identifier enter: serviceAccountKeyPath,
      • Under description: Fully-qualified path of the downloaded JSON file,
      • Under Type select String,
      • Choose the Create button.
    4. In the same way, you will create a second variable named userEmail also of type String. Choose + Create.

      Create User Email
    5. After the Environment Variables are created successfully, close the project properties window.

  • Step 3

    The Google Authorization SDK is a collection of activities allowing you to acquire authorization with Google to perform activities in the Google Workspace and the Google Document AI SDK. It is mandatory for authorizing SAP Build Process Automation to Google Applications. It contains activities to support authorization mechanisms such as Service Account and OAuth. The Authorize activity must be used before any Google SDK Activity and the Disconnect activity must be used at the end of the automation.

    1. Select Settings.

    2. In the Project Properties window, select Dependencies.

      In the Manage Dependencies section, you can see that the Core and Excel SDK were added automatically when the automation was created.

    3. Choose Add Dependency and select Add a Business Process project dependency.

      Add Dependency
    4. Under Package, select Google Authorization SDK and choose a version.

    5. Choose Add.

      Google Authorization SDK

      The Google Authorization SDK has been added successfully.

    6. You may close the Project Properties window.

      Google Authorization SDK
    7. In the Automation Details panel, under Tools, search for Google.

      The Google Authorization activities will be displayed.

      Google Authorization SDK

    Which SDK do you need to authorize Google within SAP Build Process Automation ?

  • Step 4

    After successful completion of setting the Service Account as mentioned in the pre-requisites, you would have downloaded the Service Account Key in JSON format and saved it safely on your local machine to avoid credential leakage, which is a major risk when using the service account approach.

  • Step 5

    The Authorize Google (Service Account) activity is used to authorize using service account and the same activity is supported on Desktop Agent 2.0 and Desktop Agent 3.0. Once the activity executes successfully, the bot is authorized to execute any subsequent google activities.

    The Bot using Service Account Authorization doesn’t require any human intervention such as providing the user consent or credentials. Hence this will be a suitable choice for unattended scenarios.

    To perform actions on behalf of the user, Domain Wide Delegation must be enabled for the service account, and the user’s email address is mandatory. For instance, the user’s email is required in order to send emails or schedule events on the Google calendar. However, neither the user’s email address nor Domain Wide Delegation are required for services like Google Document AI and Vision AI.

    1. In the Automation Details panel, under Tools, search for Authorize Google (Service Account).

    2. Drag and drop the activity into the workflow.

      Authorize Google
    3. Choose the activity.

    4. Under Input Parameters, for serviceAccountKeyPath field enter the environment variable E serviceAccountKeyPath previously created.

      Service Account Key Path
    5. Choose the field of the input parameter Scopes and select Create Custom Data.

      Create Custom Data

      Select GmailScope and GoogleDriveScope if the automation contains Gmail and Drive Activities for instance.


      userEmail is the user’s email address to perform actions on behalf of them. Domain-wide delegation is mandatory if user’s email is provided.

    6. For userEmail field enter the environment variable userEmail previously created.

    7. Choose Save.

      User Email
  • Step 6

    You can test if the Google Authorization has been set up correctly.

    1. Choose Test.

    2. Fill in the Environment Variables:

      • For userEmail: your user email
      • For serviceAccountKeyPath: the full path to the json file
    3. Choose Test.


      The testing was successful.

      Test result

      Now that you have set the Authorize activity, you may add Google Workspace SDK to automate google applications such as google drive, Gmail and google sheet. Once you are done building your automation, you may use the Disconnect activity at the end of the automation.

Back to top