Setting up the External Calendars
Before you synchronize events created for assignments and project task assignments with the external calendar, it is recommended that you complete the initial setup.
An authentication provider, a named credential, and an external calendar service provider app like Google are required to set up Google Calendar within PSA. Salesforce provides Google as a predefined authentication provider to identify the users and manage access.
Contact your IT team to setup Google as an authentication provider.
Configure Google as an authentication provider
- Browse to the Google Cloud Platform https://console.cloud.google.com/.
- Log in to the Google Cloud Platform using your email and password. If you are a first time user select the Terms of Service check box and click AGREE AND CONTINUE.
- Contact your IT team to setup a new Google project. To create a new project, navigate to navigation menu and click IAM & Admin| Create a Project.
- Specify the following details:
- Enter the project name in the Project name field.
- Select the organization name to attach the project in the Organization drop-down.
- Browse the parent organization or folder in the Location field.
- Click CREATE. It directs you to the Dashboard.
- Select the newly created project from the Select a project drop-down on the top left-hand side next to the Navigation menu.
- Specify the following details:
- If you are an existing user and have an existing project, select it from the Select a project drop-down on the top left-hand side next to the Navigation menu. Contact your IT team to grant you the access to this project, to enable APIs.
- To enable the Google Calendar API in your project, open the Navigation menu and click APIs & Services| Enabled APIs & services. The APIs & Services page displays.
- Click +Enable APIS and Services. The API Library page displays.
- In the Search field, type “Calendar API” and press Enter on the keyboard.
- Select Google Calendar API. Click Enable.The API/Service Details page displays.
After creating the project and enabling the API, you can now configure the OAuth consent screen, follow the steps from Configuring the OAuth consent screen & registering your app in Google section.
Configuring the OAuth consent screen & registering your app in Google
- On the APIs & Services page, select the OAuth consent screen from the navigation pane on the left-hand side.
- Select the User Type as either “Internal” or “External”.
- Internal: select the user type as “Internal” if you are creating the app within the organization. In this case, there is no need to publish and verify the app.
- External: if you are creating an app outside of your Google Workspace organization then select the User Type as “External”. Depending on how you configure your OAuth screen, you need to publish the app in production and submit it for verification.
- Click CREATE. The App information section displays.
- In the App information section:
- In the App name field, enter the name of your app asking for consent at the time of authorization. You can keep the App name can be similar to the Google project name for better usability.
- In the User support email field, enter an email where users can contact you regarding their consent. For example, your IT help desk email.
- [Optional] In the App logo field, upload a logo for your app.
- Under the App domain section, in the Authorised domains, click +ADD DOMAIN and enter force.com in Authorised domain 1 field. Again, click +ADD DOMAIN and enter salesforce.com in Authorised domain 2 field.
- In the Developer contact information section Email Addresses field, enter email addresses where Google can notify you about changes in your project.
- Click SAVE AND CONTINUE.
- To add the authorization scopes, click ADD OR REMOVE SCOPES.
- In the Update selected scopes window in the filter input field, select API and enter Google Calendar API.
- Scroll down and select the scope with the user-facing description as “View and edit events on all your Calendars”. You can select others scopes as well but this scope is the minimum requirement for this functionality to work.
- Click UPDATE.
- Click SAVE AND CONTINUE. The app registration summary is displayed.
- [Optional] To make changes to the app registration, click EDIT.
You have now successfully authenticated and registered your app. Now create credentials to access your enabled APIs. Follow the steps in Generate Google Credentials: Client ID and Client Secret section.
Generate Google Credentials: Client ID and Client Secret
- On the APIs & Services page, select the Credentials from the navigation pane on the left-hand side.
- Click + CREATE CREDENTIALS and select OAuth client ID.
- On the Create OAuth client ID page, in the Application type drop-down select "Web application".
- In the Name field, enter a name for the web client.
- Leave the Authorised redirect URls blank to copy the Callback URL generated from the Authorization Provider Setup at the Salesforce end.
- Click CREATE. The Client ID and Client Secret is created.
- Copy "Your Client ID" and "Your Client Secret" from the OAuth client created popup window for setting up the Auth. Provider in Salesforce and click OK.
After successfully completing the Google setup and generating the Client ID and Client Secret, you need to set up Google as an authentication provider in your Salesforce org.
Authentication Provider Setup
You can configure Google as an authentication provider in your Salesforce org from the Auth. Providers Setup page.
- From Setup, in the Quick Find box, enter Auth. Providers, select Auth. Providers and click New.
- In the Provider Type drop-down, select "Google". After the selection, the auth. provider fields are displayed.
- Enter the details in the following fields and leave all other fields blank:
- In the Name field, enter a name for the authentication provider.
- The URL Suffix field populates automatically as soon as we complete the Name field.
- In the Consumer Key field, paste the Google Client ID copied in Step 7 of Generate Google Credentials: Client ID and Client Secret section.
- Similarly, in the Consumer Secret field, paste the Google Client Secret created in Step 7 of Generate Google Credentials: Client ID and Client Secret section.
- In the Authorize Endpoint URL field, enter the following URL: https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force
- In the Token Endpoint URL field, enter the following URL: https://accounts.google.com/o/oauth2/token
- In Default Scopes, enter the following scopes separated by a space:
- openid
- https://www.googleapis.com/auth/calendar.events
- Click Save.
- Copy the Callback URL generated under the Salesforce Configuration section.
- Navigate to Google setup, in the Navigation menu, click APIs & Services| Credentials.
- On the Credentials page, under OAuth 2.0 Client IDs, click the Edit OAuth client icon.
- Scroll down to the Authorised redirect URIs section, click +ADD URI and paste the Callback URL in the URIs 1 field.
- Click SAVE.
- Navigate to your Salesforce org Auth Provider, which you have created in Step 1 to Step 4 . Use the Test-Only Initialization URL to test the connection. It redirects you to the Google Account login page. Select the account and click Allow to view and edit events on all your calendars.
For example, openid https://www.googleapis.com/auth/calendar.events
After a successful connection, you will receive a success response similar to the one below:
Generating Named Credentials
A named credential specifies the URL of a callout endpoint and is used for authentication. We have two ways to create a named credential in Salesforce, Named Credential using external credential and New Legacy.
Creating named credential using new Named Credential setup page
To create a named credential using the new Named Credential setup page, you must create an external credential. External credentials specify an authentication protocol and permission sets or profiles to use when authenticating to an external system.
-
Create External Credential
Follow these steps to create an external credential:
- From Setup, enter “Named Credentials” in the Quick Find box, then select Named Credentials.
- Click External Credentials| New. A New External Credential window opens.
- In the Label field, enter a name for the external credential.
- In the Name field, enter a unique name containing underscores to refer to the external credential.
- In the Authentication Protocol, select OAuth 2.0.
- In the Authentication Provider drop-down, select the authentication provider name.
- Leave the Scope blank if you have defined it in the specified authentication provider else enter the Scope.
- Click Save. The Named Credentials page opens up.
- Scroll down to the Permission Set Mappings section, and click New. The Create Permission Set Mapping window opens.
- To create a permission set mapping for this external credential, select a permission set from the Permission Set list.
- In the Sequence Number field, enter a sequence number. A sequence number specifies the order of principals to apply when a user participates in more than one principal.
- Select one of the following from the Identity Type:
- Named Principal: to apply the same credential or authentication configuration for the entire org.
- Per User Principal: to provide authentication configuration at an individual user level.
- Click Save.
-
Create Named Credential
The external credential is created and now to create a named credential and link it to the external credential perform the following steps:
- From Setup, enter “Named Credentials” in the Quick Find box, then select Named Credentials.
- Click the Named Credentials tab.
- To create a named credential, click New. The New Named Credential window opens.
- In the Label field, enter a name for the named credential. For example, named credential google.
- In the Name field, enter a unique name containing underscores to refer to the named credential . You can use the same name specified in the Label field. For example, named_credential_google.
- In the URL field, enter https://www.googleapis.com.
- In the External Credential drop-down, select the name of the external credential.
- Ensure that Generate Authorization Header is selected under the Callout Options.
- Under the Managed Package Access section, in the Allowed Namespace field enter ”pse”.
- Leave the rest of the fields as they are and click Save.
-
To authenticate the external credential when the Identity Type is "Named Principal"
- Open the External Credentials tab, and now click the external credential name to open the external credential page.
- Navigate to Permission Set Mappings.
- Under Actions, select "Authenticate".
-
To authenticate the external credential when the Identity Type is "Per User Principal"
When authenticating external credential using Per User Principal, the user must be added to the correct permission set for this external credential.
Ensure that the users must follow the steps for per-user authentication:
- In the upper right-hand corner, click the profile icon.
- Click Settings.
- In the Quick Find box, enter “External Credential”.
- To authenticate the external credential, in the external credential card, click Allow Access.
- The authentication flow starts. For example, enter a username and password and click Allow on the consent screen.
- The external credential is now authenticated and the external credential card shows “Authenticated.”
- [Optional] To revoke authentication on the external credential, click Revoke Access.
Creating named credential using New Legacy setup page
To generate the named credential using Legacy, follow these steps:
- From Setup, in the Quick Find box, enter Named Credentials.
- Select Named Credentials, and click New Legacy.
- In the Label field, enter a label. The Name field auto-populates as soon as you specify the label.
- In the URL field, enter https://www.googleapis.com.
- Select one of the following:
- Set Identity Type as "Named Principal" for org-level authentication.
- Set Authentication Protocol as OAuth 2.0.
- For the Authentication Provider, click the lookup and select the Auth. Provider that was created earlier from the Search Results on the lookup.
- In the Scope field, enter the scope to override the scope provided in Auth. Provider. If left blank the Scope field picks the Scope from the Auth. Provider.
- Select the Start Authentication Flow on Save checkbox.
- Leave the Callout Options as they are.
- Click Save. The Named Credential is created.You are now redirected to Google sign in.
- Select the account you want to choose and click Allow view and edit events on all your calendars on the consent screen.
- Set Identity Type as "Per User Principal" for per user authentication.
- Set Authentication Protocol as OAuth 2.0.
- For the Authentication Provider, click the lookup and select auth. provider that was created earlier from the Search Results on the lookup.
- In the Scope field, enter the scope to override the scope provided in Auth. Provider. If left blank the Scope field picks the scope from the Auth. Provider.
- Deselect the Start Authentication Flow on Save checkbox, as it is a Per User authentication.
- Leave the Callout Options as they are.
- Click Save. The Named Credential is created.
You need to create a new permission set or edit an existing one for the users to access this Named Credential.
- In the newly created permission set, select Named Credential Access.
- Click Edit.
- Click Add to add the Named Credential from the Available Named Credentials section to Enabled Named Credentials section.
- Click Save.
You can now assign the permission set to the users to whom you want to give access to the named credential.
Ensure that the users must follow the steps for per-user authentication:
- In the upper right-hand corner, click the profile icon.
- Click Settings.
- Navigate to Authentication Settings for External Systems under My Personal Information.
- On Authentication Settings for External Systems, click New.
- In the External System Definition field Named Credential is already populated, if not select Named Credential.
- Similarly, the named credential created for Google calendar is already populated in the Named Credential field.
- In the User drop-down, select the user.
- The Authentication Protocol field is pre-populated with OAuth 2.0.
- To start the authentication flow, select the Start Authentication Flow on Save checkbox.
- Click Save. You are now redirected to Google sign in.
- Select the account you want to choose and click Allow view and edit events on all your calendars on the consent screen.
Once the authentication is done, you must copy the named credential API name and follow the steps in Enable Custom Settings section for the users to use this functionality.
Enable Custom Settings
In order to control and customize this functionality, you can use the External Calendar Events Settings custom setting. For more information, see External Calendars Integration with PSA Settings.
The following custom setting fields are mandatory for this functionality to work:
- Named Credential for Google
- Sync PTA with External Calendar
- Sync Assignment with External Calendar