Creating a Workflow Web Service Method that Uses Google OAuth 2.0

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.

Create Google Credentials

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

Google Restrictions

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:

  1. Go to Google Sheets, and log in with the same account you just registered your application in the previous step.
  2. Click the + Blank button.
  3. Enter a name for your spreadsheet.
  4. Click into the top left cell, A1, and type “Last Processed Ticket.”
    Create a Google Sheet
  5. Copy the Sheet's ID. In the spreadsheet URL, the ID is the string of random characters sandwiched between two slashes.
    Google Sheet ID
    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:

  1. In TDAdmin, click Applications in the left navigation.
  2. Click the desired Application Name in the table.
  3. In the left navigation, click Workflow Web Services, then Web Service Auth Accounts.
  4. Click the New button.
  5. Enter a Name.
  6. Click the Account Type dropdown and select Google OAuth 2.0.
  7. Make sure the Active checkbox is checked.
  8. Optionally enter a Description.
  9. Enter the Client ID and Client Secret values that you created when you registered your application with Google.
  10. 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.


    New Google Auth Account
  11. Click on the Generate Tokens buttons.
  12. When prompted, enter your Google account username and password.
  13. When prompted, grant permissions for offline access.
  14. 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:

  1. In TDAdmin, click Applications in the left navigation.
  2. Click the desired Application Name in the table.
  3. In the left navigation, click Workflow Web Services, then Web Service Providers.
  4. Click the New button.
  5. For the Name field, let's call it "Google Sheets API".
  6. 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.
    Google Sheets Web Service Provider
  7. Give the provider a useful description.
  8. Mark it as active.
  9. Click Save.

Configuring the Web Service Method

To create the web service method that communicates with Google's servers:

  1. In TDAdmin, click Applications in the left navigation.
  2. Click the desired Application Name in the table.
  3. In the left navigation, click Workflow Web Services, then Web Service Methods.
  4. Click the New button.
  5. Enter a useful Name that indicates what this API call is going to do.
  6. Click the Base Web Service Provider URL dropdown and select Google Sheets API.  This will automatically fill in the URL for you.
  7. Change the web service type from GET to POST.
  8. 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.
     Web Service URL
  9. Click the Parameters tab and enter the following:
    1. Provide "TicketID" as the Name
    2. Select Integer as the Type
    3. Choose the "From Ticket" option
    4. Select ID as the ticket field
    5. Click +Add
      Once finished, you'll see the parameter count increase from 0 to 1.

Web Service Parameters

  1. Click the Body tab and paste the following into the field:
     
    	{
    	  "range": "A2:A2",
    	  "majorDimension": "ROWS",
    	  "values": [
    	    [{{TicketID}}]
    	  ],
    	}	

    Web Service Body
  2. Click the Authentication tab and select Google Authentication.
  3. Click the Test Request button.
  4. Provide a value for the TicketID parameter.
    Test Web Service Request
  5. 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.

Google Sheet Web Service Method Result

  1. 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.

Details

Article ID: 21977
Created
Mon 12/12/16 3:23 PM
Modified
Wed 9/29/21 10:33 AM

Related Articles (1)

This introduction article will help Ticketing Admins to configure Web Service Auth Accounts in the Ticketing application.