Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
netchild opened this issue Oct 1, 2023 · 2 comments · May be fixed by #138
Open

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

netchild opened this issue Oct 1, 2023 · 2 comments · May be fixed by #138

Comments

@netchild
Copy link

netchild commented Oct 1, 2023

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 ).

@Atomique
Copy link

Atomique commented Nov 23, 2023

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

@PatBriPerso
Copy link

PatBriPerso commented Mar 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants