Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Use graphToken IF personal token fails
Browse files Browse the repository at this point in the history
  • Loading branch information
runely committed Jun 1, 2022
1 parent bef3336 commit bcd7a08
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/get-user-tasks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { CACHE } = require('../config')
const getGraphToken = require('./graph/get-graph-token')
const getVismaTasks = require('../lib/visma/get-visma-tasks')
const getPlannerTasks = require('../lib/planner/get-planner-tasks')
const getOutlookTasks = require('../lib/outlook/get-outlook-tasks')
Expand Down Expand Up @@ -37,6 +38,12 @@ module.exports = async (context, graphUser, token, force = false) => {
try {
if (token) outlookTasks = await getOutlookTasks(context, token, userPrincipalName)
} catch (error) {
const graphToken = await getGraphToken(context)
try {
if (graphToken) outlookTasks = await getOutlookTasks(context, graphToken, userPrincipalName, true)
} catch (error) {
context.log.error(['tasks', 'get-user-tasks', userPrincipalName, 'get-outlook-tasks', 'err', error])
}
}

try {
Expand Down

0 comments on commit bcd7a08

Please sign in to comment.