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

OAuth 2.0 - Client credentials always returning "'undefined' is not valid JSON" #2452

Open
2 tasks done
eduardoscamargo opened this issue Jun 12, 2024 · 3 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@eduardoscamargo
Copy link

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

I am trying to send a request using OAuth2 - Client Credentials. No matter the content of the credentials parameters I get a message Error invoking remote method 'send-http-request': SyntaxError: "undefined" is not valid JSON.

(Screenshot has mocked values, I tested with the real/correct values and got the same error message)

Version: v1.19.0

.bru file to reproduce the bug

No response

Screenshots/Live demo link

image
@eduardoscamargo eduardoscamargo added the bug Something isn't working label Jun 12, 2024
@gemiusz
Copy link

gemiusz commented Jun 14, 2024

@eduardoscamargo I can't reproduce this:
image

Please provide bru file with this issue.

I'm not sure how this functionality should work so need explanation from any DEV :)
As I see when I set URL as 'test' then is going POST to 127.0.0.1:80 :

2024-06-14 18:50:19.391 Request received:
127.0.0.1 - POST /test

Accept: [application/json, text/plain, */*]
Content-Type: [application/x-www-form-urlencoded]
request-start-time: [1718383819286]
User-Agent: [axios/1.7.2]
Content-Length: [74]
Accept-Encoding: [gzip, compress, deflate, br]
Host: [localhost]
Connection: [close]
grant_type=client_credentials&client_id=test&client_secret=test&scope=test


So I think that in your case something send response that cannot be parsed correctly.
Can you provide this response ?

@sylvainlegault
Copy link

Not sure if that can help but I have the same issue, this seems to happen when using GraphQL as a simple post works for the same oauth2 settings.
There is nothing logged in the console nor in Timeline just showing < Error
Looks like the request are never sent. Might be because Graphql is not JSON

@sylvainlegault
Copy link

Did some troubleshooting, but I don't know the code base enough :(

But the problem seems to be related to this part from ipc/network/index.js


    // if this is a graphql request, parse the variables, only after interpolation
    // https://github.com/usebruno/bruno/issues/884
    if (request.mode === 'graphql') {
      request.data.variables = JSON.parse(request.data.variables);
    }

I tried skipping this but doesn't solve the issue, I get further without exception but I get the auth response instead of the graphql response, so something else is not working. Looks like oauth2 doesn't play well with graphql and doesn't continue with the grapqh request itself.

I cannot share my environment since this is a private endpoint. But I can help with testing any fixes if needed.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants