[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Ftpapi] Authentication type =Bearer with token



Les,

In the current beta version of httpapi (http://www.scottklement.com/httpapi/beta) you can do this:

http_setAuth(HTTP_AUTH_BEARER: '': YourToken);

In older versions you have to build the header yourself using an HTTP_POINT_ADDL_HEADER callback.

Also -- I do not understand why you are calling http_persist_open in your example.  What is that meant to do? 

-- 
Scott Klement
sk@xxxxxxxxxxxxxxxx

On 4/8/2021 10:28 AM, Les Turner wrote:

I have a requirement to get data from a secure API. It requires a certificate in the DCM, which I have set up.   Then I have to make 2 calls.

 

The first one is a POST and you use basic authentication to pass a UserID and password to get back a token in the response body.   This is working with this code:

 

    // Open persistent connection

    pComm = http_persist_open(URL);

 

    // Set credentials

    http_setauth(HTTP_AUTH_BASIC: username: passwd);

 

   // use the certificate in the DCM

     app_id = 'ADP_APPLICATION';

 

     rc = https_init(app_id);

     if rc = -1;

        http_comp(http_error());

        https_cleanup();

        return;

     endif;

 

    response = http_string('POST': URL: postdata: 'application/json')  ;

 

I am able to extract the token from the Response variable.   The problem is with the second call.   That token is then used in the second request which makes a GET to return the data stream.  However the second request uses authentication type “Bearer” and I don’t know how to code for that with HTTPAPI.

 

I can make it work in Postman by pasting the token into the header authorization variable with the word Bearer.    I would appreciate any help you can give on how to pass a bearer token with HTTPAPI.    Thanks!

 

 

Les Turner

Developer

Information Technology

ManhattanLife Insurance

T: 713-821-6414

 


-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi