Get client_credentials token with base64 encoded client/secret in header with League/Oauth2 client

49 views Asked by At

I'm implementing a service integration with an oauth2 authentication with client credentials grant type.

In postman I can get the token in the final request itself, by using the Authorization tab. I must set "Client Authentication" as "Send as Basic Auth header" otherwise I get an "unauthorized_client" error.

When I try to get the token in my code, using https://github.com/thephpleague/oauth2-client It simply doesn't work throwing each time the "unauthorized_client" error.

This is because it's behaving as postman with the "Send client credentials in body" option set.

Is there an option I'm missing to do the same thing with the oauth2 client? If I take a look at the Postman console, it's clear that it sets an "Authorization" header, with "Basic xxxxxx" where xxxxxx is the Base64 encoding of clientID:clientSecret for the request that asks for the token.

While if it sends the cliend_id / client_secret as body params it throws that error.

0

There are 0 answers