Awesome
Google Mirror Sample App
<a href="https://githubsfdeploy.herokuapp.com?owner=financialforcedev&repo=ffhttp-googlemirror-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 Mirror and Core libraries.
It consists of two components:
- A test harness that provides a UI for performing all of the Google Mirror API calls.
- An implementation of the library that shows how it can be used to create an approval process involving Google Glass.
Unlike the other sample apps (e.g. Dropbox and Google Drive), this app requires a lot more configuration to get it working and a little further explanation.
###Application flow The app makes use of two extensions to the Core library. The Google Mirror library itself (see the calls in GoogleMirrorService) and a simple Salesforce-to-Salesforce HTTP client (see GoogleMirrorSalesforceService).
After creating a requisition and submitting it for approval, a message is sent to Google Glass (via the Mirror API) to create a timeline item (see GoogleMirrorApprovalProcess). At this point, the user wearing Glass can see an item in their timeline with the requisition details. Selecting this requisition in Glass gives the user the options to approve and reject it. When one of these options is selected, an anonymous API call is sent from Glass to Salesforce (see GoogleMirrorCallback). This call is then directed to the appropriate user via a Salesforce-to-Salesforce API call (see GoogleMirrorSalesforceService). This callback is processed, updating the requisition appropriately (see GoogleMirrorAuthenticatedCallback)
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/glass/v1/reference/.
- Demonstrates the use of the Timeline: insert API call to add a requisition to Google Glass.
- Demonstrates the use of the Subscriptions: insert API call to subscribe to changes on the Glass timeline.
- Demonstrates the use of the Subscriptions: delete API call to unsubscribe from changes on the Glass timeline.
- Demonstrates the use of a callback mechanism for Salesforce-to-Salesforce API calls.
Configuration
This section explains how to configure the Google Mirror Sample App.
###Salesforce Organisation Setup
####Register Domain
- Go to Setup > Domain Management > My Domain.
- Enter a domain name and select Register Domain.
- Make a note of your domain name as you will need this in the Create a Connected App and Deploying the project sections e.g. https://test-ed.my.salesforce.com/
- Go to Setup > Security Controls > Remote Site Settings.
- Select New Remote Site, enter Self Internal as the name and the domain name as the URL.
####Sites
- Go to Setup > Develop > Sites.
- Enter a domain name, accept the terms of use and select Register My Force.com Domain.
- Make a note of your domain name as you will need this in the Deploying the project section e.g. https://test-ed-developer-edition.na16.force.com/
- Go to Setup > Security Controls > Remote Site Settings.
- Select New Remote Site, enter Self as the name and the domain name as the URL.
####Create a Connected App
- Go to Setup > Create Apps.
- Select New in the Connected Apps section.
- Enter a Connected App Name, App Name and Contact Email.
- Select Enable OAuth Settings.
- As the callback URL enter the domain name (from step 3 in the Register Domain section) with apex/connector appended e.g. https://test-ed.my.salesforce.com/apex/connector
- Choose Full access(full) as the Selected OAuth Scopes.
- Save the connected app.
- You should be redirected to the Connected App page.
- Make a note of the Consumer Key and Consumer Secret as you will need these in the Deploying the project section.
###Create a Google App
- Log in to your Google Plus account registered to your pair of Google Glasses.
- 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.
- Expand the APIs & auth section.
- Select APIs.
- Enter Mirror in the Browse APIs section.
- Turn the Google Mirror API on.
- Select the Consent screen.
- Enter a Product Name, make sure the Email Address is set and save.
- Select Credentials.
- Select Create new Client ID.
- Select Web application.
- Set the Authorized Javascript Origins url to the domain name (from step 3 in the Register Domain section) e.g. https://test-ed.my.salesforce.com/.
- Set the Authorized Redirect URIs to the same as above with apex/connector appended: e.g. https://test-ed.my.salesforce.com/apex/connector.
- Make a note of the Client Id and Client Secret as you will need these in the Deploying the project section.
###Deploying the project
- Deploy the Core, Google Mirror and OAuth Client Sample App packages to your Salesforce organisation.
- Deploy the Google Mirror Sample App to your organisation.
- If the Google Mirror Sample App app shows in the app menu then go to step 9.
- Otherwise, go to Setup > Manage Users > Users.
- Select your user.
- Select Edit Assignments in the Permission Set Assignments section.
- Add the Google Mirror Sample App Permissions permission set and Save.
- The Google Mirror Sample App project should display in the app menu.
- Select the Google Mirror Sample App project.
- The Test Harness, Requisitions, Connector Types, Connectors tabs should be displayed.
###Create the required Connectors in Salesforce
-
Go to the Developer Console.
-
Open the Execute Anonymous window from the debug menu.
-
Execute the following code from the window replacing each of the parameters with the appropriate values.
GoogleMirrorConfigure(<ORG_DOMAIN>, <ORG_SITES_DOMAIN>, <GLASS_CLIENT_ID>, <GLASS_CLIENT_SECRET>, <GLASS_CALLBACK_CLIENT_ID>, <GLASS_CALLBACK_CLIENT_SECRET>);
- ORG_DOMAIN = Salesforce Organisation Setup - Registered Domain
- ORG_SITES_DOMAIN = Salesforce Organisation Setup - Registered Site Domain
- GLASS_CLIENT_ID = Google App Client Id
- GLASS_CLIENT_SECRET = Google App Client Secret
- GLASS_CALLBACK_CLIENT_ID = Connected App Consumer Key
- GLASS_CALLBACK_CLIENT_SECRET = Connected App Consumer Secret
-
Go to the Connector Type tab and check that you have two connector types: Google Glass Approvals and Salesforce for Mirror Callback.
-
Go to the Connectors tab and check that you have two connectors for your user e.g. Google Glass Approvals for Joe Bloggs and Salesforce for Mirror Callback for Joe Bloggs.
-
Select both connectors in turn and activate them by selecting Activate then Authorize.
-
For the Google Glass Approvals connector, select Mirror Subscriptions then Subscribe. This will subscribe you to the Google Glass timeline.
###Modify the Salesforce API Profile
- Go to Setup.
- Search for API Profile and select it.
- Go to the Enabled Apex Class Access section and select Edit.
- Add GoogleMirrorAuthenticatedCallback and GoogleMirrorCallback to the Enabled Apex Classes section and save.
- Edit the profile and go to the Custom Object Permissions section.
- Select Modify All for all the objects (Connectors, Connector Types, Google Mirror Items & Requisitions).
- Save the profile.
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.
###Google Glass Requisition Sample App
- Create a new Requisition and save.
- Choose to submit the requisition for approval, choosing the user that Google Glass is linked to.
- You should be able to see the requisition in Google Glass.
- Choosing the requisition gives you the four options: 'Read Aloud', 'Approve', 'Reject' and 'Delete'.
- Choose to approve the requisition.
- The record should update in Salesforce.
Reporting Issues & Enhancements
Please report any issues using the github issues feature. Suggestions / bug reports are welcome as are extensions containing additional functionality.