You are viewing limited content. For full access, please sign in.

Question

Question

refresh_token in Web Service Connection

asked on April 28

I have set up a Web Service Connection to an external endpoint to retrieve an access token. I selected "Basic authentication", filled in the Client ID and Secret as username and password, and in my actual request body I used the grant_type "refresh_token" which worked successfully.

I want to set up some calls that use that access token. In Postman, I just set the Auth Type to Bearer Token and fill in the token from the first call. But this is not a choice in Laserfiche.

My choices are "No authentication", "Basic authentication" (username and password), and "OAuth 2.0 authentication" whose only choices are Client Credentials (which forces grant_type to client_credentials) or Resource Owner Password Credentials (which forces grant_type to password).

How can I use my access token to make some API calls?

Thanks,

0 0

Answer

SELECTED ANSWER
replied on April 28 Show version history

As Kevin points out, you can certainly use a token from a previous activity as an input parameter in another Web Request Rule as I show below.  Use the variable picker on the right of the field to add an input parameter, then pass in the previous token in the workflow.

1 0

Replies

replied on April 28

I'm not certain if it works the same way for Cloud vs on-prem, but, if you click the gear in the top right of your "HTTP Web Request" activity, you can modify the Request Headers section to add the Authorization header using the bearer token from your previous activity.

1 0
replied on April 29

I was unable to use the OAuth 2.0 Web Service Connection type with a refresh token based auth endpoint as well. Instead I used no authentication but the web rule will not return a token that contains your access token (used in the header of the next request). It only returns the response content and you must pattern match to get the access token, with this pattern. You can add a track tokens to your workflow to see the response content and see how to build your patterns.

"access_token":"([^"]+)"

Now in your actual endpoint calls, just include the header Authorization: Bearer %(Pattern Matched Access Token)

0 0
replied on April 29

Hi Chad,

I am using a Business Process instead of a Workflow, but in my case there was no pattern matching necessary. I just went to my Web Request, clicked the Response tab, changed Parse Type to Json, scrolled down to Response Body and put "Access Token" for Output Name and "access_token" for Parsing String since that's what it is called in the JSON.

It seems to follow the same syntax I have used in the past for parsing JSON in On Prem Workflow, which is JPATH. For example, for the code below, if I want to retrieve the "id" that is in the "person" group (5678), my Parsing String was ..person..id

{

    "id": "1234",

    "descriptor": "Person Name",

    "person": {

        "id": "5678",

        "email": "test@test.com"

    }

}

1 0
replied on April 29

Oh I see, you can add output tokens right into the rule to get values from the json response. That is a really great alternative for the fact that the JPATH activity is missing in cloud.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.