google-drive-connector
Web icon

Google Drive Connector

Stable version 2.1.1 (Compatible with OutSystems 11)
Other versions available for 10 and Older
Uploaded
 on 03 June 2020
 by 
OutSystems MVPs
4.6
 (37 ratings)
google-drive-connector

Google Drive Connector

Documentation
2.1.1

Getting started
Before you start using the Google Drive Connector, there are a few steps you must take. Since the Google Drive Connector relies on the OutSystems Platform's REST capabilities, you must:

    - Create a Google account;
    - Activate Google Drive API;
    - Retrieve your Application ID, Application Secret and API Key;
    - Fill in the configuration data.

Create a Google Account
In order to start using the Google Drive Connector, you'll need to have an account in Google. If you haven't got one already, you can create it here.

Activate Google Drive API
Activation of API is done using Google Developers Console.  Please follow this link to open the Console page.
You’ll be redirected to the Console Dashboard. It’s required to create a project to proceed. Click on the ‘Create Project’ button.


Click ‘Create’ on the next window:


In the ‘New Project’ Screen give an appropriate name to Project, select ‘Organization’ (if available) and select ‘Location’. Click ‘Create’.


After project creation, you’ll be redirected to Dashboard. Find Google Drive API among API and services and open it.


Click ‘Enable’ on Google Drive API page. You’ll be redirected to the main screen of Google Drive API



After all, you'll be redirected to API dashboard. Your Google Drive API is now Activated.



Retrieve your Application ID, Application Secret and API Key

Click ‘Create Credentials’ on the main screen of Google Drive API. Later on you can use ‘Credentials’ menu item to reach management functionality for credentials.

Select ‘Google Drive API’, and ‘Web server’ options from drop-down lists presented on the screenshot below. Also please select ‘User data’ from radio-button options. Then click ‘What credentials do I need?’ to go to the next screen.


Enter a proper name for new OAuth credentials, server address, and authorized redirect URIs. Example on the screenshot below. Then click ‘Create OAuth client ID’.



On the OAuth 2.0 consent screen select the appropriate email address and enter product name. Note: The product name will be shown to the users of your application during access authorization.
Then click ‘Continue’.

You’ll get Client ID. It will be required for application configuration later. Click ‘Done’ to proceed.


It’s required to create API key to access your application. Go to ‘Credentials’, select ‘Create credentials’ and ‘API key’.



A new API key will be created. Press ‘Close’ to proceed.


This is how you should look at your Credentials page: it contains OAuth 2.0 credentials and API key.



You can change your application settings (application name, logo, homepage link etc)  in OAuth consent screen:


For proper configuration of Demo application, you’ll need to have: Client ID, Client Secret, API Key, and Scope. Let's get Client ID, Secret and API key from Credentials page:

Go to ‘API key’ and OAuth 2.0 client ID to get the required information:


Now you’re ready to proceed with Demo application configuration.


Fill in the configuration data


Open Configuration page, enter retrieved API Key, Client ID and Client Secret to proper fields and press 'Save'


Now you're ready to use demo application.


Setting up your Application

Now that you have checked that everything is good , it's time to start coding.
Almost every method in the Google Drive API needs an authorization code. To get it, one needs to redirect users to Google Drive and handle the callback from it, in order to get the referred authorization code. Fortunately, we have got you covered. All you need to do is to import the HandleNoAccessTokenException page from the Google Drive Connector.



Then, when a user hits a page and there's no authorization code in session, an exception will be raised. Handling this exception will give you the ability to explain to your user that you need to access his profile and offer navigation to the Google Drive page. To achieve it, we tweaked the default "Internal Error" page, which is where your user will land when Google Drive detects an issue with the request and added the logic to catch this exception and present a button that navigates to the Google Drive authorization page - the HandleNoAccessTokenException page. When the user allows access to his profile, he will be redirected automatically to the page where he was before. The button that shows up to the user is depicted in the next image:


A closer look at the button will show that your user will be redirected to the HandleNoAccessTokenException page. For your convenience, we allow you to pass the keys that you need for the authentication to this page, and the callback will be handled for you. Note that in the following example, we are storing the API Key, Client ID, and Client Secret as site properties. Nevertheless, feel free to use whatever you like the most.



Congratulations! You now know everything you need when it comes to the Google Drive Connector. But, before you try to conquer the world with the Connector, we advise you to play a bit with the demo. Tweak it around, change some settings. This will probably be the best way to have a great start, and bring Google Drive to your enterprise!

Have fun!