Hi @zwifi thanks a lot for your reply. I do dynamic client registration. So based on your answers, here’s what I do now.
Dynamic client registration
final response = await http.post(Uri.parse(regEndPoint),
headers: <String, String>{
'Accept': '*/*',
'Content-Type': 'application/json',
'Connection': 'keep-alive',
'Accept-Encoding': 'gzip, deflate, br',
},
body: json.encode({
"application_type": "web",
"scope": "openid, profile, offline_access",
"grant_types": ["authorization_code", "refresh_token"],
"redirect_uris": reidirUrlList,
"token_endpoint_auth_method": "client_secret_basic",
}));
The response I get for this registration request is as follows:
response = {"application_type":"web",
"grant_types":["authorization_code","refresh_token"],
"id_token_signed_response_alg":"ES256",
"require_auth_time":false,
"response_types":["code"],
"subject_type":"public",
"token_endpoint_auth_method":"client_secret_basic",
"post_logout_redirect_uris":[],
"require_pushed_authorization_requests":false,
"dpop_bound_access_tokens":false,
"client_id_issued_at":1710377438,
"client_id":"eGKzO3ArtyRq5Fl2",
"client_secret_expires_at":0,"client_secret":"G2uxR3VA7D...",
"redirect_uris":["http://localhost:4400/"],
"scope":"openid profile offline_access",
"registration_client_uri":"https://solidserver.url/.oidc/reg/eGKzO3ArtyRq5Fl2",
"registration_access_token":"d3rlVyYJFlfAZ7qMO..."}
I then create a client
object using the above response details and after that I do the Authorisation request as follows:
var h = base64.encode('${client.clientId}:${client.clientSecret}'.codeUnits);
json = await http.post(client.issuer.tokenEndpoint,
headers: {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br',
'content-type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic $h',
'Connection': 'keep-alive',
},
body: {
'grant_type': 'refresh_token',
'code': code,
'redirect_uri': redirectUri.toString(),
'client_id': client.clientId,
'code_verifier': _proofKeyForCodeExchange['code_verifier']
},
client: client.httpClient);
But when I do this now I get the following error.
Unhandled Exception: OpenIdException(invalid_request): missing required parameter 'refresh_token'
When I change the grant_type
in the Authorisation request to authorization_code
, the request goes through, but I still do not get a refresh_token.
I am sure I am doing something wrong with these requests, but could not figure out exactly what. Any help would be much appreciated.