-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update App Insights, track custom events (#28)
- Loading branch information
Showing
12 changed files
with
310 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Graph helper module, far more lightweight than the massive Graph SDK | ||
// ------------------------------------------------------------------------- | ||
// Ben C - Sept 2022 | ||
// | ||
|
||
import axios from 'axios' | ||
|
||
export async function getUserDetails(accessToken) { | ||
try { | ||
const graphReq = { | ||
url: 'https://graph.microsoft.com/v1.0/me', | ||
headers: { Authorization: accessToken }, | ||
} | ||
|
||
const resp = await axios(graphReq) | ||
return resp.data | ||
} catch (err) { | ||
console.log(`### 💥 ERROR! Failed to get user details ${err.toString()}`) | ||
} | ||
} | ||
|
||
export async function getUserPhoto(accessToken) { | ||
try { | ||
const graphReq = { | ||
url: 'https://graph.microsoft.com/v1.0/me/photo/$value', | ||
responseType: 'arraybuffer', | ||
headers: { Authorization: accessToken }, | ||
} | ||
|
||
const resp = await axios(graphReq) | ||
return new Buffer.from(resp.data, 'binary').toString('base64') | ||
} catch (err) { | ||
console.log(`### 💥 ERROR! Failed to get user photo ${err.toString()}`) | ||
} | ||
} |
Oops, something went wrong.