Skip to content

Commit

Permalink
Add some debug traces
Browse files Browse the repository at this point in the history
  • Loading branch information
nad-au committed May 3, 2024
1 parent 98e9435 commit 680eb6d
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions monorepo/actionstep-auth/src/action-step-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,31 @@ export const actionStepAuth = (
token: async (forceRefresh?: boolean): Promise<ActionStepToken> => {
logger?.debug(`Get token (forceRefresh: ${forceRefresh})`)
if (store) {
accessToken = authCode.createToken(await store.get())
logger?.debug(`Getting token from store`)
const storedToken = await store.get()
logger?.debug(`Retrieved token: ${storedToken}`)
logger?.debug(`Parsed retrieved token: ${JSON.stringify(storedToken)}`)
accessToken = authCode.createToken(storedToken)
logger?.debug(`Created access token: ${accessToken}`)
logger?.debug(`Parsed access token: ${JSON.stringify(accessToken)}`)
}

if (accessToken.expired() || forceRefresh) {
logger?.debug(`Token is expired. Refreshing...`)
accessToken = await accessToken.refresh({ scope })
if (store) await store.set(toActionStepToken(accessToken.token))
logger?.debug(`Storing refreshed access token ${accessToken}`)
if (store) {
const storedToken = toActionStepToken(accessToken.token)
logger?.debug(`Created token for storage: ${storedToken}`)
logger?.debug(
`Parsed token for storage: ${JSON.stringify(storedToken)}`,
)
await store.set(storedToken)
}
logger?.debug(
`Successfully stored refreshed access token ${accessToken}`,
)
}

return toActionStepToken(accessToken.token)
},
api_url: config.api_url,
Expand Down

0 comments on commit 680eb6d

Please sign in to comment.