Skip to main content

Google Drive

Configure Google Cloud

  1. Go to https://console.cloud.google.com.

  2. Select a project or create a new one:

image 1

  1. Go to Enabled APIs & services.

image 2

  1. Go to Enable APIs and services.

image 3

  1. Enter google drive in the search bar and press Enter:

image 4

  1. Click Google Drive API:

image 5

  1. Click the Enable button:

image 6

  1. You should be redirected to the following screen. Go to Audience:

image 7

  1. If the following screen appears, click Get started.

image 8

  1. Complete the app information:

    App information:

    • App name: You can enter Gredit.
    • Email: You can enter your email address.

    Click Next.

image 9

  1. Audience: Select External users.

    Click Next.

image 10

  1. Contact information: You can enter your email address.

image 11

  1. Finish: Accept the Data Policy.

    Then click Create.

image 12

  1. Go to the Clients section.

image 13

  1. Go to Create client:

image 14

  1. Create the OAuth client ID:

    If Gredit is running as a web application, follow these instructions:

    • Select Web application.
    • Enter any name in Name.
    • In Authorized redirect URIs, enter the URL of your Gredit application (for example, https://test.greditsoft.com) followed by /drives/providers.

    The resulting URL in this example would be https://test.greditsoft.com/drives/providers.

    Click Create.

image 15

If Gredit is running on-premises, complete the following fields:

  • Select Web application.
  • Enter any name in Name.

Click Create.

  1. OAuth client information:

    Store the Client ID and Client secret in a secure location. You can download them in JSON format.

    Both values are required to connect the application to Gredit.

image 16

  1. Go to Data Access:

image 17

  1. Go to Add or remove scopes.

image 18

  1. Select the appropriate scopes:

image 19

Click the Update button.

Configure Google Drive in Gredit

  1. In Gredit, go to Drive -> New DRIVE Configuration.

    In Gredit:

image 20

  1. Enter the configuration details:

    • Provider: Select Google Drive.
    • Name: Enter an easily identifiable name. Example: “drive1”.
    • Client ID: Enter the Client ID provided in step 17.
    • Client secret: Enter the Client secret provided in step 17.
    • Root folder ID: Enter the ID of the Drive root folder containing the data to be consumed.

image 21

image 22

  1. You will be asked to select the account to use:

image 23

  1. Click Continue:

image 24

  1. Click Continue:

image 25

  1. Redirection:

    The successfully created configuration should then be displayed:

image 26

Using it in scripts

  1. The drive should now be mounted at the path shown in Mount point in the Google Drive configuration in Gredit.

    Directory listing example:

    Ruby:

    dir = Dir.glob("#{Rails.root}/drives/drive3/*")
    puts dir.inspect

    Python:

    from pathlib import Path

    project_root = Path("/home/ima/Escritorio/Hullop/monitor")
    files = list((project_root / "drives" / "drive3").glob("*"))
    print(files)