HTTP Auth Bearer

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
JasonWallace
Posts: 1
Joined: Fri Sep 17, 2021 6:05 pm

HTTP Auth Bearer

Post 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?
Scott Klement
Site Admin
Posts: 666
Joined: Sun Jul 04, 2021 5:12 am

Re: HTTP Auth Bearer

Post 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;
Post Reply