Highlighted
Frequent Contributor.
Frequent Contributor.
21029 views

Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

Hi Experts,

I have a token authetincation (OAuth Token) that I want to insert in a web_add_auto_hearder function to perform a REST API call by a web_custom_request.

And the way I'm do it doesn't work, once the script reach the web_custom_request the response is we don't have the authorization to make the call even the token value has been saved in a correlation parameter.

The authentication token response format is: 

    "access_token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "token_type": "Bearer",
    "expires_in": 2363

I saved access_token value in a correlation parameter to be used in the web_add_auto_header:

web_add_auto_header("Authorization","OAuth {access_token}");

also tried as

web_add_auto_header("Authorization","OAuth lr_eval_string({access_token}"));

** REST API Call

    web_custom_request("Rest Call", 
        "URL=https://xxxxxxxxxxxxxxxxxxxxx", 
        "Method=POST",  
        "Resource=0", 
        "RecContentType=application/json", 
        "EncType=application/xml", 
        "Snapshot=t6.inf", 
        "Mode=HTML",       
        LAST);

I tested the same values in SOAPUI application and I can get a response back from REST CALL.

Please advise.

Thanks

Cesar Resendiz

0 Likes
1 Solution

Accepted Solutions
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

Hi All,

The problem is now resolved, we missed to add a header with the content type

web_add_header("Content-Type", "application/xml");

also the OAuth was changed for Bearer

Now the REST Api calls can be performed correctly.

 

Thanks 

View solution in original post

0 Likes
15 Replies
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

Hi All,

The problem is now resolved, we missed to add a header with the content type

web_add_header("Content-Type", "application/xml");

also the OAuth was changed for Bearer

Now the REST Api calls can be performed correctly.

 

Thanks 

View solution in original post

0 Likes
Highlighted
Established Member..
Established Member..

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

Hi,

I am also getting the similar kind of issue. I am working in salesforce application. at one stage it is sending the OAuth authentication and getting failed at the custom request. Can you please share your code to handle this issue.

My content type is 'application/json'

 

Thanks and appreciates your help,

Kumar

 

0 Likes
Highlighted
Established Member..
Established Member..

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

In addition to the above information, I am getting the auth token

 Action.c(842):     ND":case "NO_ACCESS":case "UNSUPPORTED_LOCATION":case "ACCESS_TOKEN_RETRIEVAL_ERROR":case

 

Thanks

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

How are you capturing the token to be passed into the custom request?

Please share a screenshot or the code of your code in Vugen

Thanks

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution
Still the script is showing warning message for authentication. ..After adding the header also
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

We just did SFDC scripting in July. We got authentication error in those pages where we had to manually correlate the AuthorizationCode later and pass it in the failing request as header as web_add_header("AuthorizationCode",lr_eval_string("{CorrelationParameter}")). Apart from AuthorizationCode, other key correllations are ViewStateCSRF, ViewStateMAC, ViewState, ViewStateVersion .

 

Thanks

0 Likes
Highlighted
Visitor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

I tried to follow your solution and I cant get it right in my case. i am not able to corralate the Access_Token, can you guide on how to corralate Token ID?

 

Thanks,

Angel 

0 Likes
Highlighted
Visitor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

Cesar, I have a similar issue, can you help me out in this case.?

 

Thanks

0 Likes
Highlighted
Valued Contributor.
Valued Contributor.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

Hi, 

I need to pass my access_token to my service which is in response(JSON) of my token service,

I have tried usign web_reg_save_param_ex to get my token but no luck,

web_reg_save_param_ex(
        "ParamName=access_token",
        "LB=",
        "RB=",
        SEARCH_FILTERS,
        LAST);

attached is format of my JSON response,

Please help.

 

0 Likes
Highlighted
New Member.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

web_add_header("Content-Type", "application/xml");

web_add_header("Authorization", "(Bearer {accesstoken}"));

Highlighted
New Member.

Re: Insert OAuth Token in a web_add_header in Vugen script

Jump to solution

if needed add lr_eval_string like below

web_set_header("authorization",lr_eval_string"(bearer {accesstoken})")

 

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.