httpyac icon indicating copy to clipboard operation
httpyac copied to clipboard

OAuth2 did not retrieve AccessToken

Open thlcodes opened this issue 4 months ago • 0 comments

Hi!

First things first: great tool & VSCode extension, really enjoying it!

I only have one issue:

When trying to make openid auth work:

# @name authtest
@authtest_clientId=XXX
@authtest_tokenEndpoint=https://xxx.hana.ondemand.com/oauth2/api/v1/token
@authtest_authorizationEndpoint=https://xxx.hana.ondemand.com/oauth2/api/v1/authorize
GET /whatever
Authorization: openid authorization_code authtest

The authorization code is successfully forwarded to the httpyac auth server (looks like this: http://localhost:3000/?code=zGPZ7MZ9cJWsDebsncdZwB9qqXi&state=WoAkxmIPj6qGVqmSVJjb7Ir5Cv5), but then nothing happens: Screenshot 2024-09-27 at 12 46 08

I do not see any logs to why this happens.

When I copy the auth code and call the token request manually it works just fine and I get a response with access_token, refresh_token etc.:

# @name login
# @description 2 login with auth code
@code={{ $input code }}
POST /oauth2/api/v1/token
Content-Type: application/x-www-form-urlencoded

client_id=XXX
&redirect_uri=http://localhost:3000
&code={{code}}
&grant_type=authorization_code

I also tried interception, but this is not even called:

{{
    exports.authtest_interceptRequest = function(request, context) {
        debugger;
        console.log(request, context)
    }
}}

Any idea? Am I missing something?

Cheers Thomas

thlcodes avatar Sep 27 '24 10:09 thlcodes