Solved

Call web request with REST API and OAuth 2.0

  • 11 January 2021
  • 2 replies
  • 521 views

Badge +11

Hello All


We use SP2016 onprem with Nintex 2016 Workflow v.4.6
I am looking for a way to use the Web Request to authenticate to a service via REST APPI and OAuth.

 

Is this possible?

The provider we use [Dracon] have stated this:

 

In order to obtain a token, you need to send a POST request to our token endpoint https://[host]/oauth/token
 

POST
Header:
Authorization: Basic $client_auth

Body:
grant_type = password
username = $user_name
password = $password

 

You need an OAuth client to authenticate – for simplicity, we used the client "DRACOON Legacy scripting support". Once the flow works correctly, it can be updated to a custom own app.
The variable $client_auth​ consists of a Base64-encoded string of $clientID:$clientSecret​
For the above mentioned OAuth client, the Client ID is dracoon_legacy_scripting and there is no client secret, therefore the string to convert to Base64 is dracoon_legacy_scripting:​ and equals ZHJhY29vbl9sZWdhY3lfc2NyaXB0aW5nOg​.

 

I have tried to perform the steps by using the WEB REQUEST:

9842i8F50BD4C9B9391E9.jpg

When executed the following error appears:

 

Response status code: 401 Response content: {"error":"invalid_client","error_description":"Client authentication needed."}

 

 

Viewing the process via F12 > Network > JSON Response

 

"Response status code: 401 Response content: {""error"":""invalid_client"

icon

Best answer by bimi82 12 January 2021, 17:21

View original

2 replies

Badge +11

UPDATE


 


I figured out that the value for the Authorization attribute, needed the Basic word. In other words the TokenValue needed to have the Basic word in front of it seperated by a space.


 


 


Basic TokenValue

 


 


Now, the token is given by the OAuth server.


The result is stored into a Variable: StoreResults [MultiLine of Text].


 


Next challange:


 


- to crawl through the [StoreResults] variable


- look out for the TokenValue which starts with "access token":"


- store the TokenValue into a Strong [theToken]


 


 

Badge +11
The next challange:
https://community.nintex.com/t5/Nintex-for-SharePoint/Look-into-a-MultiLine-of-Text-variable-and-store-a-specific/m-p/121146/highlight/false#M77235

Reply