NGINX-Demos icon indicating copy to clipboard operation
NGINX-Demos copied to clipboard

oauth2-token-introspection-oss throws interbediate value toBytes is not a function

Open netchild opened this issue 1 year ago • 2 comments

For line 22 in oauth2.js the code throws a TypeError: (intermediate value)["toBytes"] is not a function (even after adding the missing semicolons in #119 ).

netchild avatar Oct 01 '23 16:10 netchild

Having the same problem trying to use this example. Can someone help out here?

Edit: Found something, but dont know how to get this working at the moment,

Since 0.8.0, the support for byte strings and byte string methods were removed. When working with byte sequence, the Buffer object and Buffer properties, such as r.requestBuffer, r.rawVariables, should be used.

http://nginx.org/en/docs/njs/reference.html#string_tobytes

Atomique avatar Nov 23 '23 15:11 Atomique

I try to use oauth2-token-introspection-oss too and I confirm that toBytes does not exist anymore.

I change the line 22 from: authHeader = "Basic " + basicAuthPlaintext.toBytes().toString('base64'); to: authHeader = "Basic " + basicAuthPlaintext.toString('base64'); and it works.

Then I have had a second issue: reply.responseBody does not exist anymore. So I replace it by reply.responseText and I'm able to validate my token.

PatBriPerso avatar Mar 07 '24 12:03 PatBriPerso