-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(core): add me & expose functions and models #4
Conversation
d171a68
to
7f7d88a
Compare
packages/core/src/api/profile.ts
Outdated
try { | ||
baseUrl = (await AuthClient.getInstance().getDataLayer().getConfigData()).baseUrl; | ||
accessToken = await AuthClient.getInstance().getAccessToken(); | ||
} catch (error) { | ||
throw new AsgardeoUIException( | ||
'JS_UI_CORE-ME-M-NF', | ||
'Failed in getting the base URL and access token.', | ||
error.stack, | ||
); | ||
} | ||
|
||
if (!accessToken) { | ||
throw new AsgardeoUIException('JS_UI_CORE-ME-M-IV', 'Access token is null.'); | ||
} |
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.
Shall we extract this logic to a reusable function? Retrieving the access token is going to be reused by many methods I guess.
Ideally, it should be the end users responsibility to pass the correct payload and headers to getProfileInformation
function. The SDK should not make token requests for each API call, IMO.
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.
In the core SDK, only this function is getting the access token. So retrieving access token won't be reused.
End user will be accessing either a custom hook to get user information or will use the profile component directly. In these scenarios we cannot expect the the end user to pass any payload or headers, as it will degrade the user experience.
Purpose
Related Issues
Related PRs
Checklist
Security checks