Monday, July 27, 2020

Create a REST Message - How to read the Docs - Integration Part 2

Hi Developers,
This is the second article in the series for integrating ServiceNow with Google Calendar to schedule a meeting.
You need to follow the steps mentioned in the first article to continue with this post.
Step 1) Navigate to System Web Services > Outbound > REST Message and click 'New'
Step 2) Give it a unique name
Step 3) Copy and paste the below URL in the filed 'Endpoint'
https://www.googleapis.com/calendar/v3
This information is available on Google Calendar API reference
Step 4)  Select the Authentication Type as 'OAuth 2.0'
Step 5) Select the '
When a new OAuth provider is created, the system automatically generates a default profile for it without any scope
Step 6) Make sure the Accessible from value is selceted as 'All application ccopes' and click 'Submit'
Step 7) Open the record again and from the 'HTTP Methods' related list open 'Default GET'
Step 8) Fill the form with the information provided below :
Name : Create an Event
HTTP Method : POST
Endpoint : https://www.googleapis.com/calendar/v3/calendars/${calendarId}/events
Authentication type : OAuth 2.0
Content-Type : application/json
Put the below script in the 'Content' field' and click 'Update'
{
  'summary': 'Google I/O 2015',
  'location': 'Online on Meet',
  'description': 'Testing Google Calendar APIs.',
  'start': {
    'dateTime': '2020-07-21T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'end': {
    'dateTime': '2020-07-21T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'howtoreadthedocs@gmail.com'},
    {'email': 'ewbsri9@gmail.com'}
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 1440},
      {'method': 'popup', 'minutes': 10}
    ]
  }
}
Step 9) Click on the related link 'Auto-generate variables'
Step 10) In the related list 'Variable Substitutions' update the record 'calendarId' by setting the value to 'primary'
Step 11) Click 'Get OAuth Token'
Step 12) Select your gmail account
Step 13 ) Click 'Advanced'
Step 14) Click 'Go to service-now.com (unsafe)
Step 15) Click 'Allow' at each of the below steps to grant permissions
Congratulations, So far we have built a rest message to schedule a meeting. 
Thank you,
Vishal Ingle
ServiceNow Certified System Administrator
DxSherpa Technologies Pvt. Ltd.
Maharashtra, IN.

Integrate Google Calendar With ServiceNow - How to read the Docs - Integration Part 1

Hi Developers,
I'm back and this time I am going to guide you to Schedule a Google Meet from ServiceNow.
In this first part I'll be guiding you on how to connect ServiceNow with Google APIs for Calendar. 
In next parts we will be discussing how to create a REST Message and use it to schedule a meeting.
So let's begin. ..

Step 1) Visit https://developers.google.com/calendar and click 'Sign in'
Step 2) Login with your Gmail credentials
Step 3) Navigate to the section 'Reference' and select 'insert' under 'Events' menu options
Step 4) In new tab visit https://console.developers.google.com/, Select your country, accept the terms and click 'AGREE AND CONTINUE'
Step 5) Click 'CREATE PROJECT'
Step 6) Give it a unique name and click 'CREATE'
Step 7) Click 'ENABLE APIS AND SERVICES'
Step 8) Search for calendar and select 'Google Calendar API'
Step 9) Click 'ENABLE'
Step 10) Select 'Credentials' from menu options

Step 11) Click 'CREATE CREDENTIALS' and select OAuth client ID'
Step 12) Select 'CONFIGURE CONSENT SCREEN'
Step 13) Select 'External' and click 'CREATE'
Step 14) Give it a unique name
Step 15) Click 'Save'
Step 16) Navigate back to Credentials and select 'OAuth client ID' under 'CREATE CREDENTIALS' 
Step 17) Select Application type as 'Web application' and give it a unique name

Step 18) Click 'CREATE'
Step 19) Note down the OAuth 'Client ID' & 'Client Secret' and click 'OK'
Step 20) Click the download icon beside your Client ID
Step 21) Open the downloaded json file in text editor
Step 22) In ServiceNow, Navigate to System OAuth > Application Registry and click 'New'
Step 23) Select 'Connect to a third party OAuth Provider'
Step 24) Give it a unique name and copy to fill the information (client_id, auth_uri, token_uri, client_secret) from the downloaded json file opened in text editor
Step 25) Select 'Default Grant type' as 'Authorization Code'
Step 26) Under the section 'OAuth Entity Scopes' create two records as follows and click 'Submit'
Calendar : https://www.googleapis.com/auth/calendar
CalendarEvent : https://www.googleapis.com/auth/calendar.events
The above information is available and copied from the API Reference web page opened in step 3
Step 27) Open the record again and copy the Redirect URL
Step 28) Navigate back to the page opened in step 20 and click on your OAuth 2.0 Client ID record
Step 29) Click "ADD URI' under 'Authorized redirect URIs', paste the Redirect URI Copied from step 27 and click 'SAVE'
 
So here we are done with the first part of this article and we have successfully created an OAuth Connection between Google Calendar APIs with ServiceNow.
Please go through the second part of this article to learn how to create a REST Message to use this API.
Thank You,
Vishal Ingle
ServiceNow Certified System Administrator
DxSherpa Technologies Pvt. Ltd.
Maharashtra, IN.