Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it necessary to save access_Token to cache? #4603

Closed
colinin opened this issue Jul 3, 2020 · 1 comment · Fixed by #4742
Closed

Is it necessary to save access_Token to cache? #4603

colinin opened this issue Jul 3, 2020 · 1 comment · Fixed by #4742
Assignees
Milestone

Comments

@colinin
Copy link

colinin commented Jul 3, 2020

Authorization call between internal services will request IDS server to get token each time. Is it necessary to cache client or user's access_token according to grant_type and ExpiresIn after the first request is successful to reduce the pressure on IDS server for each call? Of course, the token needs to be encrypted again

This is often the case when a domain event requires the invocation of a remote service, and events are generally stateless

public virtual async Task<string> GetAccessTokenAsync(IdentityClientConfiguration configuration)
{
var discoveryResponse = await GetDiscoveryResponse(configuration);
if (discoveryResponse.IsError)
{
throw new AbpException($"Could not retrieve the OpenId Connect discovery document! ErrorType: {discoveryResponse.ErrorType}. Error: {discoveryResponse.Error}");
}
var tokenResponse = await GetTokenResponse(discoveryResponse, configuration);
if (tokenResponse.IsError)
{
if (tokenResponse.ErrorDescription != null)
{
throw new AbpException($"Could not get token from the OpenId Connect server! ErrorType: {tokenResponse.ErrorType}. Error: {tokenResponse.Error}. ErrorDescription: {tokenResponse.ErrorDescription}. HttpStatusCode: {tokenResponse.HttpStatusCode}");
}
var rawError = tokenResponse.Raw;
var withoutInnerException = rawError.Split(new string[] { "<eof/>" }, StringSplitOptions.RemoveEmptyEntries);
throw new AbpException(withoutInnerException[0]);
}
return tokenResponse.AccessToken;
}

@hikalkan hikalkan added this to the 3.2 milestone Jul 10, 2020
@hikalkan hikalkan assigned hikalkan and maliming and unassigned hikalkan Jul 10, 2020
@hikalkan hikalkan modified the milestones: 3.2, 3.1 Jul 10, 2020
@hikalkan
Copy link
Member

It seems we can work on this in 3.1. @maliming can you check how feasible it and can we implement this in this milestone? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants