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

Re: [Ftpapi] Question regarding adding addtional headers with html_xproc



Thanks to both of you for replying.  However, the problem was identical to the 2013 posting (additional header line for OAUTH2 authorization).  Where your reply showed "your code for determining the token goes here" in the subprocedure, in my case I had a separate routine that requested the token and stored it in a data area.  The service I'm accessing issues a token with a 60 minute life.  I want to cut down on trips to get one by keeping that work separate from the call to the API itself.

My question was how to get the token value into the subprocedure.  After study I realized that variables outside of the subprocedure are still global so with that my problem was solved.  Just how the "secret sauce" in HTTPAPI picks up the new header when a return from the subprocedure is not apparent is what I took on faith.  So far, the call to http_xproc is returning a zero.  The proof will be accessing the API!

Again, thanks to both of you.

Kind regards,
Jonathan R Bolton

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx <ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx> On Behalf Of Jon Paris
Sent: Monday, July 20, 2020 5:10 PM
To: FTPAPI/HTTPAPI mailing list <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [Ftpapi] Question regarding adding addtional headers with html_xproc

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.



It wasn't my original question - but as it happens I may have a use for this.  Hadn't thought about using it that way.

Thanks Scott.



> On Jul 20, 2020, at 4:59 PM, Scott Klement <sk@xxxxxxxxxxxxxxxx> wrote:
>
> On 7/20/2020 3:14 PM, Jon Paris wrote:
>> Perhaps he is looking for something similar to the XML-INTO %Handler comms area Scott?
>
> Hi Jon,
>
> If you're looking for something like the 'comm area' of the XML-INTO handler, you can use the userData option on http_xproc. The example that follows is with 32-byte bearer token, hopefully it can be adapted to different types of tokens as needed.
>
>
> **free
>
> ctl-opt dftactgrp(*no) bnddir('HTTPAPI');
>
> /copy httpapi_h
>
> dcl-ds TokenData qualified;
>   Type  varchar(20);
>   Value varchar(256);
> end-ds;
>
> dcl-s result varchar(10000);
>
>
> http_xproc( HTTP_POINT_ADDL_HEADER
>           : %paddr(Add_Token_Routine)
>           : %addr(TokenData) );
>
> TokenData.Type  = 'Bearer';
> TokenData.Value = '6996708b55829823c069b9ea2d708bf7';
>
> http_debug(*on: '/tmp/token_debug_log.txt');
>
> result = http_string( 'GET': 'http://www.scottklement.com' );
>
> *inlr = *on;
>
> dcl-proc Add_Token_Routine;
>
>   dcl-pi *n;
>      NewHeaders varchar(32767);
>      Token      likeds(TokenData);
>   end-pi;
>
>   dcl-c CRLF const(x'0d25');
>
>   NewHeaders = 'Authorization: '
>              + Token.type + ' ' + Token.value + CRLF;
>
> end-proc;
>
> --
> _______________________________________________
> Ftpapi mailing list
> Ftpapi@xxxxxxxxxxxxxxxxxxxxxx
> http://scottklement.com/mailman/listinfo/ftpapi

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