Google API

pathat
Kilo Expert

Hello.

Has anybody experiment or developed a workflow in ServiceNow that calls out to Google using the Google APIs? I'm interested in hearing about your experiences and lessons learned.

I am interested in managing users in my Google domain via the Google Directory API.

20 REPLIES 20

Tom Brown
Mega Guru

I've been trying to do the same thing to get away from using Orchestration and the GAM command line tool (Google App Manager, I think).   It has been kind of sketchy sending lists through PowerShell to execute through GAM, as I've run into issues with firewall problems and occasional temporary authentication issues.   I've also used it in the past to automatically disable email accounts when employees are terminated.



So I was looking through this document about the Google Contacts API:


Outbound REST with OAuth 2.0 profile tutorial - integrating with Google Contacts API


Which has step-by-step directions for creating the Google Project and credentials, then OAuth profile in Service Now, and finally creating a REST message.   It's a great document, except that I'm currently stuck at the point in the REST message where I request the OAuth token, as I get back a response "Unsupported OAuth grant type 'Authorization Code'."   I've gone back through the directions, recreated credentials, tried variations on what's in the document, but with no luck.   The account does have the Contacts API enabled.



So if anyone has any suggestions, I'd appreciate it.   I'm trying this on a Geneva instance with the OAuth 2.0 plugin enabled, if that's relevant.   My interest is in creating and populating Google Groups and updating calendars using the Google API.


silas1
ServiceNow Employee
ServiceNow Employee

Can you share your configuration for the OAuth Provider and the OAuth Profile? Make sure that Authorization code is selected on the OAuth Profile.



Just FYI if you install plugin "Email - OAUTH support for IMAP and SMTP" it installs a sample Google OAuth provider that you can take and modify or else create one that mimics it.


Thanks for the pointer to the Oauth support plugin.   There were a couple of lines that I changed in mine to match the one it installed, but I'm still getting this Unsupported OAuth grant type 'Authorization Code' message.   I'll put screen shots of the registration and the message below.   This is where I was trying the calendar access one in the link I posted earlier.   Am I correct in assuming that the error message is coming from the Google side of things instead of the Service Now side?


find_real_file.png



find_real_file.png


silas1
ServiceNow Employee
ServiceNow Employee

I think the problem is your OAuth API Script. Try referencing "OAuthUtil" instead of OAuthAccessToken.



To support refresh token flow with Google, you'll also have to specify some additional parameters on your authorization code request. Now that you've installed the Email OAuth plugin, you should actually have an extension to OAuthUtil called "OAuthGoogleOfflineAccess". Reference that in your OAuth API Script field. It sets the access_type=offline and approval_prompt=force parameters that will tell Google you want refresh token behavior.