Skip to content

Instantly share code, notes, and snippets.

@gamemaker1
Last active June 12, 2021 04:35
Show Gist options
  • Save gamemaker1/01eb0e7b7b1dd89ae536942c75896e60 to your computer and use it in GitHub Desktop.
Save gamemaker1/01eb0e7b7b1dd89ae536942c75896e60 to your computer and use it in GitHub Desktop.
How to create an OAuth 2.0 client for using Dabbu CLI

Hi there, and thank you for using Dabbu CLI!

Why this is required

To access your Google Drive/Gmail, Google requires developers to request user consent using the OAuth 2.0 procedure. This involves obtaining a client ID and client secret from Google, which are not supposed to be revealed to anyone. However, Dabbu CLI is open source, and we cannot embed the client ID and client secret in the code. This means that users need to create their own client ID and secret and enter it in the CLI.

In case you are adding another account (you have already followed this procedure once before)

In case you want to use Dabbu CLI with another Google account, do NOT follow the below procedure: instead, simply leave the client ID and client secret fields blank. When the CLI asks you to authorise the app, simply choose with the new account that you want to add to Dabbu CLI.

Create an OAuth 2.0 client from Google Cloud Console

  1. Create the project
  2. Enable the APIs required
    • Once the project is created, go to the following URL: https://console.cloud.google.com/projectselector2/home/dashboard?supportedpurview=project
    • Select the project that you just created.
    • Click on the ≡ icon on the top left
    • Click on API & Services
    • Click on the blue ENABLE APIS AND SERVICES button
    • Now search for the API you want to enable
      • If you want to access your Google Drive, search for Google drive and click on the first result. Then press the enable button
      • If you want to access your Gmail, search for Gmail and click on the first result. Then press the enable button
      • If you want to access your Google Photos, search for Google photos library and click on the first result. Then press the enable button
  3. Configure the consent screen
    • Once you have enabled one or more APIs that you need, click on the ≡ icon on the top left
    • Hover over API & Services, then click Credentials
    • Click on the blue CREATE CREDENTIALS button
    • Click on OAuth client ID
    • Click on the blue CONFIGURE CONSENT SCREEN button
    • Fill in the fields as follows:
      • User type: EXTERNAL
      • Then press CREATE
      • Then on the OAuth Consent Screen page:
        • App name: Dabbu CLI
        • User support email: select any one from the dropdown
        • Developer contact information: enter your email address
        • Then press SAVE AND CONTINUE
      • Then on the Scopes page:
        • Press ADD OR REMOVE SCOPES
          • In the popup on the right side, scroll down to the bottom. A textbox should be there, with the text Manually add scopes above it.
          • Enter the following in that textbox: https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/gmail.modify, https://www.googleapis.com/auth/photoslibrary (The last one - https://www.googleapis.com/auth/photoslibrary - can be skipped/omitted, as the Google Photos provider is planned but not yet implemented)
          • Click ADD TO TABLE
          • Click UPDATE
        • Then press SAVE AND CONTINUE
      • Then on the Test users page:
        • Press Add Users
          • In the popup on the right side, enter the email address for the account(s) you intend to use the app with
          • Press ADD
        • Then press SAVE AND CONTINUE
      • Then on the Summary page:
        • Press the blue BACK TO DASHBOARD button
  4. Create the OAuth client
    • Once you have configured the consent screen, click on the ≡ icon on the top left
    • Hover over API & Services, then click Credentials
    • Click on the blue CREATE CREDENTIALS button
    • Click on OAuth client ID
    • Fill in the fields as follows:
      • Application type: Web application
      • Name: Dabbu CLI
      • Authorized redirect URIs:
        • Press Add URI
        • Enter http://localhost:8081 and press enter
      • Press the blue CREATE button
      • You should see a popup on the screen, with the title OAuth client created. Copy the client ID and client secret given in the popup and paste it into the CLI one by one.

Follow the rest of the instructions on screen to access your Google Drive from Dabbu CLI.

Thank you!

Hi there, and thank you for using Dabbu CLI!

Why this is required

To access your One Drive, Microsoft requires developers to request user consent using the OAuth 2.0 procedure. This involves obtaining a client ID and client secret from Google, which are not supposed to be revealed to anyone. However, Dabbu CLI is open source, and we cannot embed the client ID and client secret in the code. This means that users need to create their own client ID and secret and enter it in the CLI.

In case you are adding another account (you have already followed this procedure once before)

In case you want to use Dabbu CLI with another Microsoft account, do NOT follow the below procedure: instead, simply leave the client ID and client secret fields blank. When the CLI asks you to authorise the app, simply choose with the new account that you want to add to Dabbu CLI.

Create an OAuth 2.0 client from Microsoft Azure Portal

  • Open https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredApps in a web browser.
  • Click on the New Registration button.
  • Fill in the following text boxes with these values
    • Name: Dabbu CLI
    • Type: Web
    • Accounts: Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
    • Redirect URI: http://localhost:8081
  • Then click on the Register app button. Copy the client ID you get and enter it here.
  • Then go to APIs permissions and click on Add a permission > Microsoft Graph API > Delegated permissions > select Offline access and Files.ReadWrite.All. Then click on Add permission.
  • Then go to Certificates and Secrets and create a new secret and set expiry date to Never. Copy the client secret you get on that webpage and enter it in the CLI.

Follow the rest of the instructions on screen to access your One Drive from Dabbu CLI.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment