Reputation: 1462
I have a Blazor SPA and a registered client in Identity Server 4 .
I take username and password from user a create an access token request to my identity server 4.
var client = new HttpClient();
var response = await client.RequestPasswordTokenAsync(new PasswordTokenRequest
{
Address = "...",
ClientId = "360.WASM",
ClientSecret = "...",
Scope = "BulutTakin.Appraisal360.WASM",
GrantType="password",
UserName = username,
Password = password,
});
everything is just fine and I get access token as expected but RefreshToken is null.
I want to implement RefreshToken feature in my app and for now I want to get a refresh token when I request an access token.
I was wondering why refresh token is null in my response.
I read the IS4 documentation and it says:
Refresh tokens are supported for the following flows: authorization code, hybrid and resource owner password credential flow. The clients needs to be explicitly authorized to request refresh tokens by setting AllowOfflineAccess to true
I have set Allow Offline Access to true in my Identity Server 4 Admin Dashboard as well.
this is the response I get:
And this is my client configuration:
any help on getting this done is appreciated.thanks.
Upvotes: 1
Views: 992
Reputation: 1462
We just need to add offline_access
scope to our scope parameter.
var response = await client.RequestPasswordTokenAsync(new PasswordTokenRequest
{
Address = "...",
ClientId = "360.WASM",
ClientSecret = "...",
Scope = "BulutTakin.Appraisal360.WASM offline_access",
GrantType="password",
UserName = username,
Password = password,
});
Upvotes: 1