# Google Cloud Storage Integration

Google Cloud Storage requires several steps to configure.

You will start at the API credentials manager:\
[https://console.developers.google.com/projectselector/apis/credentials](https://console.developers.google.com/projectselector/apis/credentials)

You need to enable the GoogleStorage API for your account if its not already.\
[https://console.developers.google.com/apis/library/storage-component.googleapis.com/](https://console.developers.google.com/apis/library/storage-component.googleapis.com/)\
![Clopud storage api enable](Google-Cloud-Storage-Integration/clopud_storage_api_enable.png)

Create a new project. My example calls this "CrushFTP-Test".\
![Create project](GDriveSetup/create_project.png)

#### 1. Web Application type

Next, click on the "Create Credentials" button, and choose the Web Application type.\
![Create credentials](GDriveSetup/create_credentials.png)

It will warn you if you don't have an "OAuth Consent" screen configured, so go there and configure that screen too.\
![Oauth consent](GDriveSetup/oauth_consent.png)

When configuring the credential, you have to tell Google the domain you will be originating from when creating the auth token, so this is the URL you use for server administration. Just the protocol://dns_or_ip:port Don't have a trailing slash or it will complain.\
Configure the redirect URL of where Google will send you back after approval. This needs to follow the syntax in the example. Specifically, your domain needs to end with:

```
?command=register_gdrive_api
```

![Credential config](GDriveSetup/credential_config.png)

And one last important step, you need to enable the GoogleDrive API for your account if its not already.\
[https://console.developers.google.com/apis/library/storage-component.googleapis.com/](https://console.developers.google.com/apis/library/storage-component.googleapis.com/)\
![Clopud storage api enable](Google-Cloud-Storage-Integration/clopud_storage_api_enable.png)

Now that the API is enabled, your credentials are setup, and your redirect domains are configured, you can use the credentials in CrushFTP to get your Google auth token and get access.\
In the User Manager, add a new remote VFS item type and set the protocol to be "GStorage".\
Click "Get Refresh Token" to finish the config. Provide the client id and secret.

![Oauth form](Google-Cloud-Storage-Integration/oauth_form.png)

If your domain is not verified you will get a warning message, click on Advanced and proceed further:

![Not verified domain](Google-Cloud-Storage-Integration/not_verified_domain.png)

Click on allow:

![Allow form](Google-Cloud-Storage-Integration/allow_form.png)

The refresh token will be saved as password.\
Provide the bucket and the path.\
It is done! Test the connection and save it!\
![Bucket and test](Google-Cloud-Storage-Integration/bucket_and_test.png)

#### 2. Service Account type

Create Credentials -> Service Account.\
![Service account](Google-Cloud-Storage-Integration/service_account.png)

Provide a name and continue.\
![Service account details](Google-Cloud-Storage-Integration/service_account_details.png)

Configure the service account access.\
![Storage account access](Google-Cloud-Storage-Integration/storage_account_access.png)

Click on the "Done" button.

Navigate to the newly created Service Account. Go to the KEYS tab. Click on the "Add KEY" button, and then select "Create new key".\
![Service account new key](Google-Cloud-Storage-Integration/service_account_new_key.png)

Download the JSON file.\
![Service account private key](Google-Cloud-Storage-Integration/service_account_private_key.png)

**VFS configuration:**

Username:**google_jwt**\
Special user name for Service Account Access.\
Password:**<\<the JSON file content>>**\
It authenticates based on the provided JSON file.\
Provide the **bucket** and the path.\
It is done! Test the connection and save it!\
![Service acount vfs test](Google-Cloud-Storage-Integration/service_acount_vfs_test.png)

#### 3. Access through S3 API

Generate **Access key** and **Secret**. Got to [https://console.cloud.google.com/](https://console.cloud.google.com/) In the left sidebar of the dashboard, click Google Cloud Storage and then Settings.\
![Cloud storage sttings](Google-Cloud-Storage-Integration/cloud_storage_sttings.png)\
Select the Interoperability tab. If you haven't enabled it already, click on **Interoperable Access**. Now you should see an empty list and a **Create New Key** button. Click the button to create an **Access/Secret key** pair.

**Google Cloud S3 VFS configuration:**\
**1.**\
Domain:<\<Cloud Storage -> Settings -> INTEROPERABILITY -> Domain of **Storage URI** default is **storage.googleapis.com**>>\
Change the S3 default domain (s3.amazonaws.com) to the domain of Google Cloud Storage domain.\
User name:**<\<Access Key>>**\
Password:**<\<Secret>>**\
Bucket:**<\<Google Cloud Storage Bucket Name>>**\
**SHA256 enabled on signing (Signing Version 4)**:<\<Enabled>>\
**!Warning** Signing version 4 must be enabled, as Google Cloud Storage does not support older signing versions.

![S3 vfs settings](Google-Cloud-Storage-Integration/s3_vfs_settings.png)\
**2.** Select **GStorage** Item type.\
Enable **S3 API** flag.

Domain:<\<Cloud Storage -> Settings -> INTEROPERABILITY -> Domain of **Storage URI** default is **storage.googleapis.com**>>\
Change the S3 default domain (s3.amazonaws.com) to the domain of Google Cloud Storage domain.\
User name:**<\<Access Key>>**\
Password:**<\<Secret>>**\
Bucket:**<\<Google Cloud Storage Bucket Name>>**\
**SHA256 enabled on signing (Signing Version 4)**:<\<Enabled>>\
**!Warning** Signing version 4 must be enabled, as Google Cloud Storage does not support older signing versions.

![Gstroage s3 api vfs enabled](Google-Cloud-Storage-Integration/gstroage_s3_api_vfs_enabled.png)

More info about s3 VFS configuration: [S3 integration](S3-integration.md)
