After successfully building our first flow for ticket and question case creation for salesforces from our contact form now we want to include our incoming emails to our info account to the flow. We are having some issues after creating the google service account and allowing domain-wide access, we have followed the following steps:
Step 1: Create a Google Cloud Project
- Log in to the Google Cloud Console at https://console.cloud.google.com/.
- Create a New Project:
- Click on the project drop-down in the top-left corner next to the Google Cloud logo.
- Click âNew Project.â
- Enter a project name and select your organization. Then click âCreate.â
- Enable the Gmail API:
- In the left-hand menu, go to âAPIs & Servicesâ > âLibrary.â
- Search for âGmail APIâ and click on it.
- Click âEnableâ to enable the Gmail API for your project.
Step 2: Create a Service Account
- Navigate to Service Accounts:
- In the Google Cloud Console, go to âIAM & Adminâ > âService Accounts.â
- Click âCreate Service Account.â
- Fill in the Service Account Details:
- Enter a name for the service account and an optional description.
- Click âCreate.â
- Grant the Service Account Access to the Project:
- In the âService account permissionsâ section, you can leave it blank for now, or assign it roles like âViewerâ if needed. Click âContinue.â
- Skip the âGrant users access to this service accountâ step by clicking âDone.â
- Create and Download the JSON Key:
- After creating the service account, click on it in the list.
- Go to the âKeysâ tab and click âAdd Keyâ > âCreate New Key.â
- Select âJSONâ and click âCreate.â A JSON file will be downloaded automatically. This is the file you need to provide to your Palantir setup.
Step 3: Enable Domain-Wide Delegation (for G Suite / Google Workspace Admin)
- Edit the Service Account:
- Go back to the âService Accountsâ page in the Google Cloud Console.
- Click on the service account you just created.
- Click the âShow Domain-Wide Delegationâ checkbox under âDomain-wide Delegation.â
- Save changes.
- Set Up Domain-Wide Delegation:
- Go to the Google Admin Console at https://admin.google.com.
- Navigate to âSecurityâ > âAPI Controls.â
- Click âManage Domain-Wide Delegationâ at the bottom of the API Controls page.
- Click âAdd Newâ and enter the Client ID. The Client ID can be found on the Service Account page in the Google Cloud Console under âDetails.â
- In the âOAuth Scopesâ field, add the scopes you need. For Gmail, you would generally include:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.modifyhttps://www.googleapis.com/auth/gmail.send
- Click âAuthorize.â
Step 4: Provide the JSON Key File and Email Address
- JSON Key File: Provide the JSON key file you downloaded earlier to the user (you, in this case) who needs to set up the connection in Palantir.
- Email Address: If domain-wide delegation is set up, provide the email address of the user whose Gmail data will be accessed.
Setting Up the Connection:
- AuthScheme:
- Set this to
OAuthJWT, which indicates that youâll be using OAuth JWT for authentication.
- InitiateOAuth:
- Set this to
GETANDREFRESH. This will instruct the driver to automatically manage the OAuth tokens, including refreshing them when needed.
- OAuthJWTCert:
- Here, you need to provide the path to the JSON key file. If you are uploading it directly in Palantir, you might need to reference the file or paste the content if the interface allows.
- OAuthJWTCertType:
- Set this to
GOOGLEJSONBLOBas youâre using a JSON key file.
- OAuthJWTSubject (Optional):
- If you are using domain-wide delegation, set this to the email address of the user whose data you need to access. If you donât need to impersonate a user, you can leave this blank.
Optional: Testing the Service Account
- Use the Google OAuth Playground (https://developers.google.com/oauthplayground) to test the service account:
- In Step 1, select the required API scopes.
- In Step 2, provide the service accountâs client ID and secret if testing manually.
Final Notes
- Security: Ensure that the JSON file is stored securely, as it contains sensitive information.
- Permissions: If the service account needs more permissions, these can be adjusted under âIAM & Adminâ > âIAMâ in the Google Cloud Console by assigning additional roles.
But we are getting the following error: The explorer command failed to run: java.lang.Throwable:RemoteException: INVALID_ARGUMENT (MagritteExplorer:SqlError) with instance ID xxxxxxxxx: {reason=Failed to retrieve OAuth token information. unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested., sqlState=HY000, vendorCode=0, originalErrorInstanceId=xxxxxxxxxxx, stacktrace=com.palantir.magritte.explorer.jdbc.MagritteExplorerErrors.sqlError(MagritteExplorerErrors.java:25)



