Enable the Google Drive feature in Habitat
Posted: Tue Oct 15, 2019 4:53 pm
Best Practice
To use Google Drive to upload, download, delete, list or any other feature integration inside Habitat you will need to have a "clean" google account and the Google Drive API services enabled on that account.
A clean Google account will have a empty drive. You can use this drive just for the Automate server and the plugin integration. If you use an existing google account, you may have many files from different areas of google clouding up the storage and populating the plugins file list with photos of your kids. So its just as easy to setup a new account just for the Automate server to use for this plugin.
We will walk you through the full process:
See a video on setting up Google Drive with Habitat Click Here
It's a good idea to launch in to Chrome (not required) as your browser and select from the top icon the drop down menu to launch Google Drive. Otherwise visit google.com and search for Google Drive.
Now assuming that the browser is not "logged in" as a Google User already and if so log out and re-run the step above. You should see the following web page in browser.
Select the personal account option to be presented with a "Sign In" dialog.
Use this dialog to select the create new account link. Create your new account and complete the initial account setup process. Afterwards it should return you to the following webpage.
You should now be in your new Google Drive account looking at the default view. Inside this view you should see a single "Getting Started" file. Do not delete this file yet. We will be using it later in this example.
Once you have a general google account you need to enable the plugins access via enabling API access to your account.
Enable the Google Drive API
To get started integrating with the Google Drive UI, you need to enable the Drive API within your app's Cloud Platform project and provide configuration details. This gives you access to the API as well as access to UI integration features.
To enable the Drive API, complete these steps:
While logged in to google drive with new account, go to the Google API Console. https://console.developers.google.com/
This will prompt you to accept the TOS
Once you agree to the TOS Create a new project called "Habitat For Automate" by selecting the create link.
Put in the project name "Habitat For Automate" and Create.
We should now be inside our project, see the top of the web page for project name to be listed. Then select the link "Enable APIS and Services". This will allow you to add the Google Drive API to your account.
Find and select the Google Drive API (under G Suite).
Select to enable this API
Now we need to set up security for our project. Select the "Create Credentials" link for project.
First select to add Google Drive as the API.
Now select "Other" and the "User Data" radio button. Click the "What Credentials do I need" to continue.
Select to setup Consent Screen.
Fill in the "Application Name" with Habitat For Automate
Select to Create Credentials at the bottom of the page.
You will be presented with the following screen, select "OAuth client ID".
Select the "Other" radio button, type in the name "Habitat For Automate" and select create.
It will present you with a long URL string as a client ID and a secret key.
Save this Client ID and KEY safely. You will take that information and inside the Habitat plugin. Select the Configure button in main menu of the Habitat plugin to input this info.
Configure Habitat Plugin
On the Habitat Control Center tab you will find the Google Drive plugin icon. This will launch the Google drive file manager. From this window you can select Configure Access to add in the newly created keys and authorizations.
You can take your new ClientID and Key and add it to the plugins configuration.
Upon first launch of the plugin, the plugin installs the Google Drive API dll files to the LabTech Client install folder. Once you have configured the API with a ClientID you can close and relaunch the file manager to start the permissions and login process for the API. This will be handle in a browser upon relaunch of the API.
On relaunch of the file manager with a newly added Client ID, allow a few more seconds for it to launch. It is calling out to google to verify ClientID. It will force a launch of the default browser with google asking to choose an account. Select or add the account you used to create the Google Drive account above. (Not the API credentials but the google account)
You will get a warning that the API Creds you are using (ClientID) is not verified. It belongs to you so you know its safe.
Select to expand the advanced link to accept responsibility for the ClientID credentials your providing.
And then select the Allow when prompted.
And Again confirm your choice.
Now remember that Getting Started file we left in our google drive for later? Yeap, we are now going to use that file to confirm that we are indeed connected and working with Google Drive. Select to Refresh File List
It should come back pretty fast with an update showing you that one file in your google drive currently. it will also allow you to download that file or remove it if needed. This data is now in the Automate database for you to access when needed.
Cool Beans!
To use Google Drive to upload, download, delete, list or any other feature integration inside Habitat you will need to have a "clean" google account and the Google Drive API services enabled on that account.
A clean Google account will have a empty drive. You can use this drive just for the Automate server and the plugin integration. If you use an existing google account, you may have many files from different areas of google clouding up the storage and populating the plugins file list with photos of your kids. So its just as easy to setup a new account just for the Automate server to use for this plugin.
We will walk you through the full process:
See a video on setting up Google Drive with Habitat Click Here
It's a good idea to launch in to Chrome (not required) as your browser and select from the top icon the drop down menu to launch Google Drive. Otherwise visit google.com and search for Google Drive.
Now assuming that the browser is not "logged in" as a Google User already and if so log out and re-run the step above. You should see the following web page in browser.
Select the personal account option to be presented with a "Sign In" dialog.
Use this dialog to select the create new account link. Create your new account and complete the initial account setup process. Afterwards it should return you to the following webpage.
You should now be in your new Google Drive account looking at the default view. Inside this view you should see a single "Getting Started" file. Do not delete this file yet. We will be using it later in this example.
Once you have a general google account you need to enable the plugins access via enabling API access to your account.
Enable the Google Drive API
To get started integrating with the Google Drive UI, you need to enable the Drive API within your app's Cloud Platform project and provide configuration details. This gives you access to the API as well as access to UI integration features.
To enable the Drive API, complete these steps:
While logged in to google drive with new account, go to the Google API Console. https://console.developers.google.com/
This will prompt you to accept the TOS
Once you agree to the TOS Create a new project called "Habitat For Automate" by selecting the create link.
Put in the project name "Habitat For Automate" and Create.
We should now be inside our project, see the top of the web page for project name to be listed. Then select the link "Enable APIS and Services". This will allow you to add the Google Drive API to your account.
Find and select the Google Drive API (under G Suite).
Select to enable this API
Now we need to set up security for our project. Select the "Create Credentials" link for project.
First select to add Google Drive as the API.
Now select "Other" and the "User Data" radio button. Click the "What Credentials do I need" to continue.
Select to setup Consent Screen.
Fill in the "Application Name" with Habitat For Automate
Select to Create Credentials at the bottom of the page.
You will be presented with the following screen, select "OAuth client ID".
Select the "Other" radio button, type in the name "Habitat For Automate" and select create.
It will present you with a long URL string as a client ID and a secret key.
Save this Client ID and KEY safely. You will take that information and inside the Habitat plugin. Select the Configure button in main menu of the Habitat plugin to input this info.
Configure Habitat Plugin
On the Habitat Control Center tab you will find the Google Drive plugin icon. This will launch the Google drive file manager. From this window you can select Configure Access to add in the newly created keys and authorizations.
You can take your new ClientID and Key and add it to the plugins configuration.
Upon first launch of the plugin, the plugin installs the Google Drive API dll files to the LabTech Client install folder. Once you have configured the API with a ClientID you can close and relaunch the file manager to start the permissions and login process for the API. This will be handle in a browser upon relaunch of the API.
On relaunch of the file manager with a newly added Client ID, allow a few more seconds for it to launch. It is calling out to google to verify ClientID. It will force a launch of the default browser with google asking to choose an account. Select or add the account you used to create the Google Drive account above. (Not the API credentials but the google account)
You will get a warning that the API Creds you are using (ClientID) is not verified. It belongs to you so you know its safe.
Select to expand the advanced link to accept responsibility for the ClientID credentials your providing.
And then select the Allow when prompted.
And Again confirm your choice.
Now remember that Getting Started file we left in our google drive for later? Yeap, we are now going to use that file to confirm that we are indeed connected and working with Google Drive. Select to Refresh File List
It should come back pretty fast with an update showing you that one file in your google drive currently. it will also allow you to download that file or remove it if needed. This data is now in the Automate database for you to access when needed.
Cool Beans!