Highlighted
Regular Contributor.
Regular Contributor.
1708 views

Capture bearer access token and pass it as header later.

hi,

I am working on a web page that is sending an access token which gets refreshed every 30mins. I need to capture the token generated during authenticate and then pass the token in the web header later. I have doen the below correlation from the reponse body of web_url.

web_reg_save_param_ex(
        "ParamName=BearerToken",
        "LB=Bearer ",
        "RB=ExpireTime",
        SEARCH_FILTERS,
        "Scope=Body",
        LAST);
    

     web_url("GetBearerTokenValue", 
        "URL=xxxxx/GetBearerTokenValue?_=1529906343018", 
        "Resource=0", 
        "RecContentType=text/html", 
        "Referer=xxxxxxxx", 
        "Snapshot=t45.inf", 
        "Mode=HTTP", 
        LAST);
         
     lr_save_string(lr_eval_string("{BearerToken}"),"BearerToken1");

and in the later scripts i am adding header like this,

web_add_auto_header("Authorization","Bearer {BearerToken1}");

the above line throws the below warning when i rpelay the script,

Warning -26593: The header being added may cause unpredictable results when applied to all ensuing URLs. It is added anyway   [MsgId: MWAR-26593]

Also this number - 1529906343018 which is passed in the url, is the one which keeps changing after 30mins and it nowhere occurs in the response and is found only in the header of this particular request alone.

is my approach right?

how to rectify this?. what went wrong? is it ok to get warning in the web script. will it fail when i run in a load test.

Could someone please help on this?

0 Likes
3 Replies
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Re: Capture bearer access token and pass it as header later.

 

Hello,

Please check the document. 

Regards,

 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Capture bearer access token and pass it as header later.

Did u run the test see if it fails?If so what was the error message. Add text check and compare request and response body. If u writing some data to the server, verify if data is written sucessfully.

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: Capture bearer access token and pass it as header later.

Hello,

It is Ok to get that warning becuase whenever you add auto header function you normally get that warning and it is fine as long as your script is working as expected.

 

Thanks,

Veera.

0 Likes
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.