Skip to content

Commit

Permalink
Merge pull request #565 from iterate-ch/issue/349-google-client-id
Browse files Browse the repository at this point in the history
Tutorial to setup a Custom OAuth Client ID for Google Drive & Google Cloud Storage
  • Loading branch information
dkocher authored Aug 20, 2024
2 parents 37e3637 + d5b9396 commit 167ae53
Show file tree
Hide file tree
Showing 18 changed files with 152 additions and 6 deletions.
7 changes: 7 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ protocols/profiles/index
cryptomator/index
:::

```{toctree}
:hidden:
:titlesonly:
:caption: Tutorials
tutorials/index
```

## Support

If you have a feature request or bug to report you can open a new ticket. The pages below has all the information on how to collect relevant log files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<string>https://www.googleapis.com/auth/drive</string>
</array>
<key>OAuth Redirect Url</key>
<string>${oauth.application.identifier}:oauth</string>
<string/>
<key>OAuth Client ID</key>
<string>…</string>
<string/>
<key>OAuth Client Secret</key>
<string/>
</dict>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<string>https://www.googleapis.com/auth/devstorage.full_control</string>
</array>
<key>OAuth Redirect Url</key>
<string>${oauth.application.identifier}:oauth</string>
<string/>
<key>OAuth Client ID</key>
<string>…</string>
<string/>
<key>OAuth Client Secret</key>
<string/>
</dict>
Expand Down
10 changes: 8 additions & 2 deletions protocols/profiles/google_client_id.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
Custom OAuth 2.0 Client ID for Google Cloud Storage and Google Drive
====

Instructions to register a custom OAuth 2.0 Client ID in the [Google Cloud Console](https://console.cloud.google.com/apis/credentials). to connect to [Google Drive](../googledrive.md). For [Google Storage](../googlecloudstorage.md).
Instructions to register a custom OAuth 2.0 Client ID in the [Google Cloud Console](https://console.cloud.google.com/apis/credentials) to connect to [Google Drive](../googledrive.md) or [Google Storage](../googlecloudstorage.md).

> To use OAuth 2.0 in your application, you need an OAuth 2.0 client ID, which your application uses when requesting an OAuth 2.0 access token.
## Register Client ID

:::{admonition} Tutorial
:class: tip

Follow the [step-by-step instructions](../../tutorials/custom_oauth_client_id.md) to setup a Custom OAuth Client ID.
:::

Follow the steps in [Setting up OAuth 2.0](https://support.google.com/googleapi/answer/6158849?hl=en). From Credentials copy the client ID and client secret by choosing the action Edit OAuth client.

* Choose _Desktop app_ as the _Application type_ which will result in a Client ID with a suffix like `number-id.apps.googleusercontent.com`.
Expand All @@ -31,7 +37,7 @@ Create a custom [connection profile](index.md) with the following properties.
- `OAuth Client Secret`. Optional. Override the registered application client secret.
- `OAuth Redirect Url`. Use the reverse notation of the client id and set it like

```
```xml
<key>OAuth Redirect Url</key>
<string>com.googleusercontent.apps.number-id:oauth</string>
```
Expand Down
Binary file added tutorials/_images/APIs_Services_Client_ID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/App_Information_Client_ID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/Application_Type_Client_ID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/Client_ID_Credentials.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/Consent_Screen_Client_ID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/Enable_APIs_Client_ID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/List_of_Scopes_Client_ID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/OAuth_Client_ID_Credentials.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/Search_Google_API.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tutorials/_images/Test_Users_Client_ID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 120 additions & 0 deletions tutorials/custom_oauth_client_id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
Setup a Custom OAuth Client ID for Google Drive & Google Cloud Storage
===

This is a step-by-step tutorial to connect with a custom OAuth 2.0 Client ID for [Google Cloud Storage](../protocols/googlecloudstorage.md) and [Google Drive](../protocols/googledrive.md).

:::{contents} Content
:depth: 2
:local:
:::

## Register Client ID

- Log in to [Google Cloud Resource Manager](https://console.cloud.google.com/cloud-resource-manager) and create a new project. You will be prompted to select a name of the project.

:::{image} _images/Create_New_Project_Client_ID.png
:alt: Create new Project
:width: 800px
:::

- Navigate to _APIs & Services__Enabled APIs & services_.

:::{image} _images/APIs_Services_Client_ID.png
:alt: APIs and Services
:width: 800px
:::

- Select _Enable APIs & Services_ and search for "Google Drive API" in the search box of the API library.

:::{image} _images/Enable_APIs_Client_ID.png
:alt: Enable APIs
:width: 800px
:::

- Select _Google Drive API_ from the search results and choose _Enable_. Repeat the same for _Google Cloud Storage JSON API_ when you want to access Google Cloud Storage.

:::{image} _images/Search_Google_API.png
:alt: API Library Google Drive
:width: 800px
:::

- Navigate to _APIs & Services → OAuth consent screen_.

:::{image} _images/Consent_Screen_Client_ID.png
:alt: Consent Screen OAuth Client ID
:width: 800px
:::

- Choose _External_ from _User Type_ and select _Create_. Choose any _App Name_ and select _Save and Continue_.

:::{image} _images/App_Information_Client_ID.png
:alt: App Information OAuth Client ID
:width: 800px
:::

- Select _Add or Remove Scopes_ in the next step. Search for "Google Drive API" and enable the scope `.../auth/drive`. Repeat the same for `.../auth/devstorage.full_control` when you want to access Google Cloud Storage. Select _Update_ to confirm and _Save and Continue_ to move to the next step.

:::{image} _images/List_of_Scopes_Client_ID.png
:alt: List of Scopes OAuth Client ID
:width: 800px
:::

- Add an email address registered as a Google account after selecting _Add Users_. Confirm by selecting _Save and Continue_.

:::{image} _images/Test_Users_Client_ID.png
:alt: Test Users OAuth Client ID
:width: 800px
:::

- Navigate to _APIs & Services → Credentials_ and select _OAuth client ID_ from _Create Credentials_.

:::{image} _images/Client_ID_Credentials.png
:alt: OAuth Client ID Credentials
:width: 800px
:::

- Select _Desktop app_ for _Application type_ and enter any _Name_. Select _Create_ to continue.

:::{image} _images/Application_Type_Client_ID.png
:alt: Application Type for Credentials
:width: 800px
:::

- Copy the _Client ID_ displayed. You will need it to set up the custom connection profile in the next step.

:::{image} _images/OAuth_Client_ID_Credentials.png
:alt: OAuth Client ID Credentials
:::

## Add Custom Connection Profile

Download the [template](../protocols/profiles/google_client_id.md#sample-google-drive-with-custom-oauth-client-id-connection-profile) for Google Drive or Google Cloud Storage:
- {download}`Google Drive Custom OAuth Client ID.cyberduckprofile<../protocols/profiles/_static/Google Drive Custom OAuth Client ID.cyberduckprofile>`
- {download}`Google Storage Custom OAuth Client ID.cyberduckprofile<../protocols/profiles/_static/Google Storage Custom OAuth Client ID.cyberduckprofile>`


Use the _OAuth Client ID_ created to edit the `OAuth Client ID` and `OAuth Redirect Url` in the template connection profile leaving other keys unchanged.

```xml
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>OAuth Client ID</key>
<string>NUMBER-ID.apps.googleusercontent.com</string>
<key>OAuth Redirect Url</key>
<string>com.googleusercontent.apps.NUMBER-ID:oauth</string>
</dict>
</plist>
```

- `OAuth Client ID`. Override the registered application OAuth Client ID.
- `OAuth Redirect Url`. Use the reverse notation of the OAuth Client ID and append `:oauth` to it.


Double-click the connection profile to open and register or copy to the _Profiles_ folder in the [application support folder](../cyberduck/support.md#application-support-folder).

## Update Protocol Selection in Bookmark

The saved profile will be available in the _Protocol_ section of the [bookmark](../cyberduck/bookmarks.md#bookmark-options) configuration.
13 changes: 13 additions & 0 deletions tutorials/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Tutorials
====

:::{toctree}
:hidden:
:titlesonly:
custom_oauth_client_id
:::

Find detailed step-by-step instructions for setup, connecting and most common use-cases as well as tutorials for more complicated workarounds.

## [Setup a Custom OAuth Client ID for Google Drive & Google Cloud Storage](custom_oauth_client_id.md)
Workaround to register your own Custom OAuth 2.0 Client ID for [Google Cloud Storage](../protocols/googlecloudstorage.md) and [Google Drive](../protocols/googledrive.md) and use it with a custom connection profile instead when encountering `This app is blocked` error when accessing Google Drive or Google Cloud Storage.

0 comments on commit 167ae53

Please sign in to comment.