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?
HTTP Auth Bearer
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: HTTP Auth Bearer
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;
-
- Posts: 3
- Joined: Fri Sep 17, 2021 6:05 pm
Re: HTTP Auth Bearer
Apologies for never replying to this old post.
Yes I was able to get it work using http_xproc
Yes I was able to get it work using http_xproc