-
Notifications
You must be signed in to change notification settings - Fork 0
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
✨ 454 - Add refresh token logic to Axios client #462
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff in here.
src/jobs/ega/egaClient.ts
Outdated
if (currentToken) { | ||
return currentToken; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea for future, can check within this block if the stored currentToken is expired, and if so we can start a refresh instead of returning the expired token.
src/jobs/ega/egaClient.ts
Outdated
// Handle token refresh error | ||
throw refreshError; | ||
if (!refreshTokenPromise) { | ||
resetAccessToken(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
might be worth a comment to say "401 indicates that the stored access token is no longer valid"
src/jobs/ega/services/permissions.ts
Outdated
@@ -44,7 +44,7 @@ export const createRequiredPermissions = async ( | |||
egaClient: EgaClient, | |||
approvedUser: EgaDacoUser, | |||
requests: PermissionRequest[], | |||
) => { | |||
): Promise<number | undefined> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reading the descriptio9n and this return type, I don't know what this returns. Why is it a number, why might it be undefined?
// In practice this means that paging will stop before all unique elements are returned, as some of the total is made up of these duplicate values | ||
// Temp solution is to subtract 1 from the offset (limit - 1), which "backtracks" the paging to ensure the element that gets missed in the last array position is captured | ||
offset = offset + DEFAULT_OFFSET - 1; | ||
offset = offset + DEFAULT_OFFSET; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
🥅 455 - Error handling and retries + job reporting
Adds refresh token logic to EGA Axios client + updates for API pagination fix
EGA Client
getAccessToken
to manage current token used in the clientfetchAccessToken
for clarity. Adds error logs here to track the network connection error that has been occurring intermittently; proper error handling + retry functionality will be added in Add Failure Handling & Retry Mechanism to EGA Integration Flow #455refreshAccessToken
- new tokens will be retrieved directly from the/token
endpoint withfetchAccessToken
getPermissionByDatasetAndUserId
withgetPermissionsByUserId
.Permissions service
processPermissionsForApprovedUsers
to usegetPermissionsByUserId
. Now that the api pagination bug (mentioned in this TODO) has been fixed, theGET /permissions
endpoint allows querying for all permissions for a user in one request, using parametersuser_id
and alimit
equal to the total number of datasets in the relevant DAC.offset = offset + DEFAULT_OFFSET - 1
incrementing for pagination in same functionMain EGA Job