fusio icon indicating copy to clipboard operation
fusio copied to clipboard

Unknow Credentials When Try To Refresh Token

Open cyromancer opened this issue 3 years ago • 6 comments

Hi Chris,

when i try to using "authorization/token", grant_type=client_credentials :

Authorization: Basic bG9jYWxfdGVzdGVyOmVoU2FsYWgx
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials

i got a response, access-token, refresh_token, scope (success), but when i want to use refresh token, i get message like this :

{
    "error": "server_error",
    "error_description": "Unknown credentials"
}

i already use same basic authorization, as above when i want request new token :

Authorization: Basic bG9jYWxfdGVzdGVyOmVoU2FsYWgx
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=[refresh_token]

did i miss some configuration on scope or header or somethings ?

cyromancer avatar Mar 08 '22 06:03 cyromancer

Hi, so if you want to use the refresh_token grant type you need to provide as Authorization header the Bearer token which you have obtained previously, this means also that you must make the request before your token is actually expired.

chriskapp avatar Mar 08 '22 18:03 chriskapp

ok, i already tried but the result :

{
    "error": "invalid_request",
    "error_description": "Credentials not available"
}

and this is my header :

Authorization: Bearer [token_from_previous_request]
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=[refresh_token]

cyromancer avatar Mar 09 '22 02:03 cyromancer

Ok, could you try to use at the Authorization header your client id/secret credentials which you also use to obtain the token in the first place, then it should work, please also take a look at the OAuth2 spec s. https://datatracker.ietf.org/doc/html/rfc6749#section-6

chriskapp avatar May 22 '22 18:05 chriskapp

You can also consume the consumer/login API

### Consumer Login
POST /consumer/login
Host: localhost
Content-Type: application/json

{
  "username": "my_username",
  "password": "my_password"
}


### Refresh consumer token
PUT /consumer/login
Host: localhost
Content-Type: application/json

{
  "refresh_token": "my_valid_refresh_token"
}

N1k0h avatar Sep 13 '22 14:09 N1k0h