Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Getting an access token from OAUTH2

craigja
8 - Asteroid

Im trying to access an API that contains training information on individuals in my company - the API is using OAuth2 to issue a token but I cant get it to do that!  The developer that Im working with, has Postman installed on his machine and can request and get a token without issue but I get the following error:

{"status":"401","timeStamp":"2020-10-28T15:39:25+0000","error":{"errorId":"5b4095aa-e582-43ac-86a1-8508a3e9520c","message":null,"code":"invalid_client","description":"invalid_client","details":null}}

 

I have the Download tool setup as follows (I have put asterisks in place of the actual ClientID and Secret :

craigja_0-1603900725740.png

 

I dont see what Im doing wrong, or different from Postman!  

 

 

14 REPLIES 14
BrandonB
Alteryx
Alteryx

In Postman, can the developer click the "code" button under the save button and show you the curl code? This is the easiest way to see if you are missing something. 

 

Also, Oauth calls tend to be a GET request, but I may be wrong there.  

craigja
8 - Asteroid

Changing to GET returns this:

<cornerstoneApi>
<status>405</status>
<timeStamp>2020-10-28T16:13:44+0000</timeStamp>
<error>
<errorId>6c519deb-4e9a-4dc7-9fab-84c29122b4a8</errorId>
<message>Method not allowed</message>
<code>405</code>
<description>Method not allowed. Please see the service help page for constructing valid requests to the service.</description>
</error>
</cornerstoneApi>

 

 
craigja
8 - Asteroid

OK - I got the token, I had to change the payload - rather than me adding them in, I had to include them as fields in the input text file and then in the 'add values from these fields' section, I ticked those fields that were in the text input file:

craigja_0-1603905682189.png

Now I can get an access token and its set to expire in 3600 seconds so should be valid for an hour, so..... I then have a new download tool on a separate workflow (as I'm still getting it working, Im not passing the token to the next download or anything yet) which has the URL that I want to download from, I have changed the Payload to GET and in the headers, I pass in Authentication and my access token but I get 'CSOD Unauthorized Exception:Check your credentials.'

 

craigja_1-1603905859254.png

craigja_2-1603905888597.png

What am I doing wrong now!

BrandonB
Alteryx
Alteryx

The API might require you to do something with the token like base64 encoding it or adding Bearer in front of it. It might also be called something other than Authorization depending on what they specify. This ultimately comes down to how the vendor has implemented their API. Take a look at this link that I just found: https://anymule.com/watch-out-for-base64-encoded-api-secret-keys.html

 

Have you tried the subsequent request in Postman yet?

craigja
8 - Asteroid

I did read that thread and so tried the Alteryx Base64 encoder tool to see if that would work but I still get the same error.  The Dev can connect with no problem using Postman and he is not doing anything to encode as Base 64 either.  Kind of stumped now!  But feel we are so close....

craigja
8 - Asteroid

Nearly there......  I had to put Bearer in front of the access token and now Im in 🙂 Getting this error now: Valid Status or LOID is mandatory  

BrandonB
Alteryx
Alteryx

Is there a Status or LOID payload value that it asks for? Also sometimes the case of the payload values can be important depending on how picky the API is so Status or status could potentially make a difference. It would appear that either one is not being provided or the value being passed isn't one that is valid. 

JORGE4900
8 - Asteroid

I was having the same issue. Postman would get the Oauth2 token very simply by selecting the configuration option from the dropdown menu. When passing the client id and secret via input tool, it worked. Works great now.

alt_tush
9 - Comet

Hi Craigja,

 

I am also trying to connect the API using Alteryx.

I have the API link but i dont know how to pass it into download tool.

 

I can see in image where you pass the cient_id, client_secret, scope and grant_tyoe.

 

Could you please share some sample workflow and also it would be really helpful if you could help me with meaning of all these parameters.

 

Really appreciate your help :)

 

Thank you,

 

Labels