Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions unitylibs/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export {

async function getRefreshToken() {
try {
const { tokenInfo } = window.adobeIMS ? await window.adobeIMS.refreshToken() : {};
return tokenInfo;
const res = window.adobeIMS ? await window.adobeIMS.refreshToken() : null;
return res?.tokenInfo ?? { token: null, isGuestToken: true };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isGuestToken: true in this case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user with no valid token is treated as guest user rather than erroring out. Followed the same convention here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not the invalid case, this is the case where adobeIMS has not been loaded yet. Do we want to retry in this case?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already retrying once in the parent.

} catch (e) {
const errorMsg = (e?.message || e?.exception?.message || '').trim();
if (errorMsg === 'invalid_credentials') {
Expand All @@ -61,7 +61,7 @@ async function getRefreshToken() {

async function attemptTokenRefresh() {
const refreshResult = await getRefreshToken();
if (!refreshResult.error) {
if (!refreshResult?.error) {
return { token: refreshResult, error: null };
}
return refreshResult;
Expand Down
Loading