Page 1 of 1

HTTP Auth Bearer

Posted: Fri Sep 17, 2021 6:09 pm
by JasonWallace
Ran into an issue with http_setAuth (HTTP_AUTH_BEARER ...

The Bearer token I got on an earlier call is 1065 in length.
But the prototype for the http_setauth only allows the pePasswd to be 1024 in lenght.
So the token is being cut off.

Suggestions?

Re: HTTP Auth Bearer

Posted: Fri Sep 17, 2021 11:54 pm
by Scott Klement
Are you able to use something like this?

Code: Select all

**free

ctl-opt dftactgrp(*no) bnddir('HTTPAPI');

/copy httpapi_h

dcl-ds TokenData qualified;
  Type  varchar(20);
  Value varchar(5000);
end-ds;

dcl-s result varchar(10000);


http_xproc( HTTP_POINT_ADDL_HEADER
          : %paddr(Add_Token_Routine)
          : %addr(TokenData) );

TokenData.Type  = 'Bearer';
TokenData.Value = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+
                   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

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;

Re: HTTP Auth Bearer

Posted: Thu Jul 11, 2024 1:34 pm
by JasonWallace
Apologies for never replying to this old post.
Yes I was able to get it work using http_xproc