panva / openid-client

OAuth 2 / OpenID Connect Client API for JavaScript Runtimes
MIT License
1.83k stars 392 forks source link

v5.x doesn't work with some providers #420

Closed HitkoDev closed 2 years ago

HitkoDev commented 2 years ago

Describe the bug Some OAuth providers (notably login.microsoftonline.com) don't accept requests with Transfer-encoding: chunked, which is the default behaviour in NodeJS unless content-length header is provided.

To Reproduce Steps to reproduce the behaviour:

    request(
        {
            form: { * payload * },
            method: 'POST',
            url: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
            headers: {},
        }
    )

Expected behaviour Returns request response.

Actual behaviour Throws OPError: expected 200 OK, got: 404 Not Found.

Environment:

Additional context This was introduced by removing got dependency which took care of setting content-length header.

panva commented 2 years ago

@HitkoDev thank you for bringing it up, i'll try and fix it promptly.