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

Re: [Ftpapi] Authentication type =Bearer with token



Les,

You'll want to use the http_xproc procedure to register and exit procedure for the HTTP_POINT_ADDL_HEADER exit point.  

http_xproc(HTTP_POINT_ADDL_HEADER:%PADDR(AdditionalHeaders));     

Then define AdditionalHeaders something like this: 

DCL-PROC AdditionalHeaders EXPORT;
DCL-PI *N;
    HeaderData VARCHAR(1024);
    HeaderData = 'Prefer: respond-async' + x'0d25';
    RETURN;
END-PROC;

I've done this many times for additional header fields.  FYI - This how you did bearer tokens prior to the latest version. 

Brian 

On Mon, Apr 12, 2021 at 12:27 PM Les Turner <LesTurner@xxxxxxxxxxxxxxxxx> wrote:

Scott,

 

I have reached my next roadblock.    The API will only return 100 records unless you tell it that you want to use asynchronous processing.   In postman I have to add a line to the header that says Prefer: respond-async. This will then give a response  in the header that you then use in the next call to fetch the data asynchronously.

 

How/where do I include the Prefer: respond-async in the header?

 

I though perhaps I could include it in the postdata parameter, but that does not seem work.

 

 

  // tell it we want async processing and get response.........

    postdata = 'Prefer:respond-async' ;

    response = http_string('GET': URL: postdata: '')  ;

                                                                  

 

 

 

 

From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx <ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx> On Behalf Of Scott Klement
Sent: Friday, April 9, 2021 10:16 AM
To: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
Subject: 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


--
Brian J. Garland
Vermont Information Processing, Inc.
brian.garland@xxxxxxxxxx


This email and any files transmitted with it are confidential and intended solely for the use of the individual or company to whom they are addressed. Do not disclose, distribute, or copy this email to others outside your company. If you have received this email in error, please notify the sender immediately and delete this email from your system.
-- 
_______________________________________________
Ftpapi mailing list
Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
http://scottklement.com/mailman/listinfo/ftpapi