Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Download access token & data from the Genesys Purecloud API

Susan
6 - Meteoroid

Hi Folks

 

I want to get an access token & data from the Genesys Purecloud API.  I have tried various ways to put the information into the download tool but have not been able to get a token, let alone data!

 

The Genesys DeveloperForum doesn’t mention Alteryx & the Alteryx Community doesn’t mention Purecloud.

 

Attached is my workflow (2018.4). 

SusanDDay_0-1590034974210.png

 

 

Below are pics of each tool as well as links to the doco that specifies the input, the requests & the JSON response containing the token.

 

Don't know what I am doing wrong, but hope someone out there can spot it 🙂

Susan

 

  1. Here is my input data (client credentials are deidentified).  When I use the real ClientID & Secret & derived Authorization, I get the same DownloadData & Headers as with these dummy values
    1. SusanDDay_1-1590034974216.png
  2. These are the steps to base encode ClientID&Secret for the Authorization field
    1. SusanDDay_2-1590034974218.png
    2. SusanDDay_3-1590034974219.png
    3. SusanDDay_4-1590034974220.png
  3. Here is the download tool (I have also tried using the other URL fields from the above text input):
    1. SusanDDay_5-1590034974223.png
    2. SusanDDay_6-1590034974225.png
    3. Whether I check TokenPost on the Payload tab or not, I get the same result in DownloadData & DownloadHeaders
    4.      SusanDDay_7-1590034974227.png
    5.      SusanDDay_8-1590034974230.png
    6. SusanDDay_9-1590034974231.png
  4. The DownloadData field contains (contextid varies):

{"message":"HTTP 404 Not Found","code":"not found","status":404,"contextId":"5b25a7b0-191d-4b3c-8846-44255f518204","details":[],"errors":[]}

  1. The DownloadHeaders field contains:

HTTP/1.1 200 Connection Established

Proxy-Agent: Zscaler/6.0

HTTP/1.1 404 Not Found

Content-Type: application/json

Content-Length: 140

Connection: keep-alive

Date: Wed, 20 May 2020 22:33:39 GMT

ININ-Correlation-Id: 5b25a7b0-191d-4b3c-8846-44255...

  1. Instructions on URLs, variables and values re:
    1. The API URL (https://developer.mypurecloud.com/api/rest/)
      1.      SusanDDay_10-1590034974231.png
    2. The requests (https://developer.mypurecloud.com/api/rest/authorization/use-client-credentials.html)
      1. SusanDDay_11-1590034974237.png
7 REPLIES 7
mattreynolds
9 - Comet

Looks like they're using OAuth.

 

This means you'll likely need two Download Tools:

 

1. First one to present your credentials and receive a token in return. Double check which parts of the payload are base64 encoded, it may just be the credentials individually. 

 

2. Second download tool to pass the token to an API. The URI you have below may be scrubbed, but its likely that it will be of the form "https://api.mypurecloud.com.au/api/rest/api/v2/..."

 

Working with web services like this, it can be helpful to use a tool like Postman (https://www.postman.com/) to get the two requests down, and then build out the Alteryx tools to fit. 

 

As an alternative, you could probably leverage the Python SDK (https://developer.mypurecloud.com/api/rest/client-libraries/python/) and a Python tool to connect to the site. 

 

Hope this helps!

Matt

 

Susan
6 - Meteoroid

Thanks for responding Matt

 

Agreed re Oauth & 2 download tools.  I have checked the B64 encoding too.  If I ever get to the 2nd download tool I will try that URI "https://api.mypurecloud.com.au/api/rest/api/v2/..."  !

 

I was hoping not to have to go down the postman & python paths, but you suggesting them makes me think that might have to be the next step

- they have tutorials with Python code eg https://developer.mypurecloud.com/api/tutorials/oauth-client-credentials/?language=python&step=1.

- & if I can install postman I might work through...

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/APIs-in-Alteryx-cURL-and-Download-T...

 

Fingers crossed, let's see what another day brings!

Susan
6 - Meteoroid

Hi Everyone

 

I am posting a solution to my problem in case it helps anyone else out there to use Alteryx to pull Genesys PureCloud data.

 

The attached  workflow (2018.4) successfully pulls Client Credential data from our PureCloud instance.  The entities and permissions in the Download Data field match the first page of Role data found at https://apps.mypurecloud.com.au/directory/#/admin/directory/rolesV2.

 

Setting up the Download tools with the correct URL, Header & Payload was a process of trying different settings suggested by the Genesys doco & tutorials.

SusanDDay_0-1591922688332.png

 

There may be many solutions, but this setup worked for me:

  1. Before you can run the workflow, you need to set up an Oauth client for Client Credentials as per https://help.mypurecloud.com/articles/create-an-oauth-client/
  2. To get the client credential token
    1. Populate the text input tool in the ‘Get access token’ container
      1. Host (URL for Australia): https://login.mypurecloud.com.au/oath/token
      2. Copy ClientID and Secret from the OAUTH client you created
      3. grant_type: client_credentials
    2. Create the Authorization field.  Thanks to @Kane Glendenning who helped me populate this correctly:
      1. UrlEncode the Client Secret and Client ID
      2. ‘Basic ‘ before the encoded string
    3. Fill in the Download tool: Note the Payload tab has a
      1. custom HTTP action (which I was unable to pass in as a field for some reason) &
      2. drop down selection of Content-Type
SusanDDay_1-1591922688337.png

 

SusanDDay_2-1591922688343.png

 

SusanDDay_3-1591922688346.png

 

 

  1. To pull client credential data
    1. Populate the text input tool in the ‘Get data’ container:
      1. HostGet: https://api.mypurecloud.com.au/api/v2/authorization/roles                   
      2. GetURL: GET /api/v2/users/me HTTP/1.1                             
      3. Content-Type: application/json
    2. Create the Authorization field using the downloaded data: [token_type]+” “+[access_token]
    3. Fill in the Download tool              
SusanDDay_4-1591922688349.png

 

SusanDDay_5-1591922688352.png

 

SusanDDay_6-1591922688355.png

 

 

Here are examples of the parsed

  • Token data:

SusanDDay_7-1591922688357.png

  • Role data
    • The pic below shows the 1st 2 records of the entity data but only a small subset of the 383 fields (multiple fields for 51 different permission policies).

     SusanDDay_8-1591922688358.png

 

Hope this helps someone!!

 

All the best

Susan

jayviz
7 - Meteor

This really helps and I had an already working API workflow which no longer works when they authorization API. I am able to generate the token , however when I am using that token to read the Data API it fails.

 

Slightly different from your method, I am using Authorization as "Bearer "+[access_token].. It fails with "{"faultcode":"Server", "faultstring":"Authorization Failed"}".

 

Any thoughts ?

Jag81
5 - Atom

Hi Jay,

 

Where you able to resolve the issue and share the fix please.

 

 

Thanks

Jag

tracysackellares
5 - Atom

Hi, my colleague and I were very happy to find your workflow.  Our company recently started using PureCloud.  We are reviewing your PureCloud access workflow and are curious whether you have had to update it since 2020.   We appreciate any help you can provide. 

 

Thank you,

Tracy Sackellares

Susan
6 - Meteoroid

Hi @jayviz & @tracysackellares,

 

I am so glad my workflow helped you!!  I did that as a POC 2 years ago now and haven't touched it since.  It proved that we could get data from PureCloud & that was all we needed.  So I am sorry, but I can't offer any advice other than what I recorded in the original posts, & obviously things could have changed since then. 

 

It would be great if you could post the issues and solutions you find, so others can benefit.

 

All the best, Susan

Labels
Top Solution Authors