Discourse OAuth2 Basic

I have the exact same error as @qlands above.

My initial plan was to send the profile info in the token. Seeing it did not work, I stripped it down indenting to try the json approach. But it doesn’t even get to the point of calling the JSON file.

The error message is:

(oauth2_basic) Authentication failure! invalid_credentials: OAuth2::Error, {
  "access_token":"fa79b6fe0763862f5a8fd8",
  "token_type":"Bearer",
  "expires_in":3600,
  "scope":"profile"
} 

Do you see anything wrong with the above reply?
Why would the plugin generate an invalid_credentials error while the OAuth2 server replied a 200 with a token?

I found the problem: the header was not set to “Content-Type: application/json”. And I can see it was the same for @qlands above.

The only remaining issue for me now is the same as @nodomain : the account is created successfully but the avatar is not included. Sample response:

Body: {
  "access_token":"...",
  "token_type":"bearer",
  "expires_in":"3600",
  "scope":"profile",
  "profile" : {
    "id":1234,
    "email": "...",
    "name": "...",
    "picture": "https://somedomain.com/somevalidpicture.jpg"
  }
} 

And it is correctly parsed, since it appears in the following log:

OAuth2 Debugging: after_authenticate response: 

creds: {"token"=>"...", "expires_at"=>1702053692, "expires"=>true}
uid: 1234
info: {"email"=>"...", "name"=>"...", "avatar"=>"https://somedomain.com/somevalidpicture.jpg"}
extra: {}

I checked that the picture address is correct, and it’s size is 300x300.

Any idea for that one?

Edit: someone just created an account, and it took the picture from Gravatar. Maybe the valid picture in the json gets overriden by a blank result from Gravatar?