NGINX-Demos
NGINX-Demos copied to clipboard
oauth2-token-introspection-oss throws interbediate value toBytes is not a function
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 ).
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
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.