This introduction article will help Users to create Workflow Web Service with Google OAuth 2.0. The user must have the Ticketing application access in TDAdmin.
Overview
Workflow web services support OAuth authentication so you can create web service calls to any external system that supports OAuth 2.0 and incorporate those calls into your workflows.
For more information on OAuth 2.0 support in TeamDynamix, please see OAuth 2.0 Web Service Accounts. For more information on how to configure workflow web services, please see Getting started with web services.
Using a Web Service Method with Google OAuth 2.0
In this example, we’ll walk through creating a Google Sheet that will be updated by TeamDynamix as part of a workflow.
Registering an Application with Google
Start by following Google's steps for Creating a Google API Console project and client ID. When performing this step, make sure to use the Google account for the user that will own the spreadsheet that the TeamDynamix system will be writing to.
When registering your application, Google will prompt you for Authorized JavaScript origin which is the base TeamDynamix URL in the format of https://[yourorganization].teamdynamix.com.
For example, if you log in to TeamDynamix using the URL https://abuniversity.teamdynamix.com/TDNext/Login.aspx, then the origin you should provide is:
https://abuniversity.teamdynamix.com
When Google asks for the Authorized redirect URIs, you must provide your TeamDynamix base URL followed by:
/TDAdmin/OAuth/Callback
Using the same example as above, the redirect URI you would provide is:
https://abuniversity.teamdynamix.com/TDAdmin/OAuth/Callback
Once you've completed that process, Google will provide you with a Client ID and Client Secret. Keep track of these as you'll need them later on.
Creating a Google Sheet
To create the Google Sheet to write to in the web service method:
- Go to Google Sheets, and log in with the same account you just registered your application in the previous step.
- Click the + Blank button.
- Enter a name for your spreadsheet.
- Click into the top left cell, A1, and type “Last Processed Ticket.”
- Copy the Sheet's ID. In the spreadsheet URL, the ID is the string of random characters sandwiched between two slashes.
For example, if the URL for your sheet is https://docs.google.com/spreadsheets/d/1oRRC0tBid05MUP6emVRSCzYRceyCVoYJGzNb-0vQWK0/edit#gid=0, then the ID of your spreadsheet is 1oRRC0tBid05MUP6emVRSCzYRceyCVoYJGzNb-0vQWK0.
Keep track of your spreadsheet ID as you'll need it later.
Creating the Web Service Auth Account
Learn more about OAuth 2.0 Web Service Auth Accounts.
To create a Google OAuth 2.0 web service auth account in TeamDynamix:
- In TDAdmin, click Applications in the left navigation.
- Click the desired Application Name in the table.
- In the left navigation, click Workflow Web Services, then Web Service Auth Accounts.
- Click the New button.
- Enter a Name.
- Click the Account Type dropdown and select Google OAuth 2.0.
- Make sure the Active checkbox is checked.
- Optionally enter a Description.
- Enter the Client ID and Client Secret values that you created when you registered your application with Google.
- In the Scope field enter
https://www.googleapis.com/auth/spreadsheets
The scope you need to provide will be determined by what permissions your web service call will need. See Google's documentation for a full list of available scopes.
- Click on the Generate Tokens buttons.
- When prompted, enter your Google account username and password.
- When prompted, grant permissions for offline access.
- Click Save.
Creating the Web Service Provider for Google Sheets
To build a web service call to the Google Sheets API a web service provider for Google Sheets needs to be created:
- In TDAdmin, click Applications in the left navigation.
- Click the desired Application Name in the table.
- In the left navigation, click Workflow Web Services, then Web Service Providers.
- Click the New button.
- For the Name field, let's call it "Google Sheets API".
- Then we need to provide the base web service URL. In the case of the Google Sheets API, that URL is
https://sheets.googleapis.com/v4/spreadsheets
.
- Give the provider a useful description.
- Mark it as active.
- Click Save.
Configuring the Web Service Method
To create the web service method that communicates with Google's servers:
- In TDAdmin, click Applications in the left navigation.
- Click the desired Application Name in the table.
- In the left navigation, click Workflow Web Services, then Web Service Methods.
- Click the New button.
- Enter a useful Name that indicates what this API call is going to do.
- Click the Base Web Service Provider URL dropdown and select Google Sheets API. This will automatically fill in the URL for you.
- Change the web service type from GET to POST.
- Update the URL to be
https://sheets.googleapis.com/v4/spreadsheets/[spreadsheetID]/values/A2:A2?valueInputOption=RAW
where spreadsheetID
is the ID of the Google sheet you created earlier.
- Click the Parameters tab and enter the following:
- Provide "TicketID" as the Name
- Select Integer as the Type
- Choose the "From Ticket" option
- Select ID as the ticket field
- Click +Add
Once finished, you'll see the parameter count increase from 0 to 1.
- Click the Body tab and paste the following into the field:
{
"range": "A2:A2",
"majorDimension": "ROWS",
"values": [
[{{TicketID}}]
],
}
- Click the Authentication tab and select Google Authentication.
- Click the Test Request button.
- Provide a value for the TicketID parameter.
- Click the Send button.
If everything worked correctly, you should see a response with a status of 200 OK and your Google sheet will get updated with the value you provided for TicketID.
- Important: Make sure to click the Save button on your New Web Service method before leaving the page.
Adding the Web Service Method to a Workflow
A web service method that writes the ID of a ticket to a Google sheet can be incorporated into a workflow as a web service step. When that step of the workflow is reached, the A2 cell of your spreadsheet will get updated with the ID of the ticket that reached the step.
For more information on how to configure ticket workflow steps, please see Configuring Ticket Workflows.