Awesome
Google Drive Sample Apps
<a href="https://githubsfdeploy.herokuapp.com?owner=financialforcedev&repo=ffhttp-googledrive-samples"> <img alt="Deploy to Salesforce" src="https://raw.githubusercontent.com/afawcett/githubsfdeploy/master/src/main/webapp/resources/img/deploy.png"> </a>Summary
This app (or collection of apps) has been built to demonstrate the use of the Google Drive and Core libraries.
It consists of two components:
- A test harness that provides a UI for performing all of the Google Drive API calls.
- An implementation of the library that allows Account attachments to be transferred to Google Drive.
Note: Currently, no test coverage for the sample apps has been provided.
Key Features
- Demonstrates each of the API calls found at https://developers.google.com/drive/v2/reference/.
- Demonstrates the use of the Files: insert API call by moving an Account attachment to Google Drive.
- Demonstrates the use of the Permissions : insert API call by sharing the transferred file to all the Account contacts.
- Demonstrates the use of the Files: delete API call by deleting the file from Google Drive.
Configuration
This section explains how to configure the Google Drive Sample Apps.
- Deploy the Core package to your Salesforce organisation.
- Deploy the OAuth Sample App.
- Deploy the Google Drive package.
- Deploy the Google Drive Sample App.
- Go to Setup > Manage Users > Users.
- Select your user.
- Select Edit Assignments in the Permission Set Assignments section.
- Add the OAuth Sample App Permissions and Google Drive Sample App Permissions permission sets and Save.
- Select the Google Drive Sample App from the app menu.
- The Test Harness, Account, Connector Types and Connectors tabs should be displayed.
- Create a Google App following the steps in the Create an app in Google section below.
- Follow the steps in the Create a Google Drive Connector section below.
- Go to Setup > Customize > Accounts > Page Layouts.
- Select Edit on the Account Layout.
- Select the Buttons section.
- Add the Move Attachments to Google Drive button to the Custom Buttons section.
- Save the layout.
- Select an account from the Accounts tab.
- The Move Attachments to Google Drive button should be displayed.
Create an app in Google
- Log in to your Google account.
- Go to https://console.developers.google.com/project and select Create Project.
- Enter a project name and ok the dialog.
- Select the hyperlink for the project name that you just created.
- Select Credentials.
- Select Create new Client ID.
- Select Web application.
- Set the Authorized Javascript Origins url to the URL of the Salesforce organisation e.g. https://eu3.salesforce.com.
- Set the Authorized Redirect URIs to the same as above with apex/connector appended: e.g. https://eu3.salesforce.com/apex/connector.
- Make sure you know the Client Id and Client Secret as they will be needed later.
- Select the Consent screen.
- Enter a Product Name and save.
Create a Google Drive Connector
-
Log in to your Salesforce organisation.
-
Go to the Developer Console and select Debug > Open Execute Anonymous Window.
-
Run the following code changing the parameters to the appropriate values:
GoogleDriveConfigure.configure(<Google App Client Id>, <Google App Client Secret>, <Salesforce domain>);
-
Check that the connector has been created and activate it.
Use
Once the project is configured:
Test Harness
- Select the Test Harness tab.
- Check that you get a message starting with 'Successful authentication'. If you do not, check that all the configuration steps have been peformed correctly.
- Expand any section to display the API calls, then select Submit to test the call.
Account Transfer Sample App
- Select the Accounts tab and view an account.
- In the Notes & Attachments section select Attach File. Choose a file and attach it.
- Select the Move Attachments to Google Drive button.
- Choose an attachment and select Transfer.
- The attachment will have been transferred to Google Drive.
Reporting Issues & Enhancements
Please report any issues using the github issues feature. Suggestions / bug reports are welcome as are extensions containing additional functionality.