Open felipeschneider88 opened 1 year ago
Awesome! Could you also submit the companion Office add-in? It would be awesome to see it in action end to end 😊
Hey @felipeschneider88, would you mind recording a short video walkthrough of your hack? Any format will work. It's not required for the hackathon but it would help us showcase your work both internally at Microsoft and publicly in the community. 😊
Hello @waldekmastykarz , I will send the video tomorrow. I'm facing problems with the Office add-in to consume the web API so I will share the idea on the video. I'm not sure if I will fix it before the deadline and I prefer to share what I have
Could you please share any more information about what's not working with the add-in? Perhaps we could help you fix the issue.
Yes, Today the app is built with 2 projects. One is the web API that interact with the Microsoft graph, it has the business logic on it.
The second is an Office add-in project that uses the SSO option to get the logged user. I was able to get information about the logged user in Excel. I was also able to get info from an URL that doesn't need auth
const element = document.querySelector('#product-name');
fetch('https://testapi.jasonwatmore.com/products/1)
.then(response => response.json())
.then(data => element.innerHTML = data.name);
But when I tried to get a token from the SSO to call the web API It fails
This is the code I'm using on the Excel Add-in:
async function getCalendar() {
let userTokenEncoded = await OfficeRuntime.auth.getAccessToken({
allowSignInPrompt: true,
allowConsentPrompt: true,
forMSGraphAccess: true,
});
const element = document.getElementById("item-subject");
let path = 'https://localhost:7068/calendar'
$.ajax({
url: path,
method: "GET",
headers: {
"Authorization" : "Bearer " + userTokenEncoded
},
success: function(response) {
element.innerHTML = response.json();
}
});
}
Do I understand it correctly that your API is rejecting your token? Have you tried looking into the token at https://jwt.ms to see to which audience it's issued and if that audience is valid with your API?
Hello, I have checked and the audience is the same (both apps are using the same AD registered in azure) with id 22969033-cb4f-4019-b265-fd9e8056f2ff
I have uploaded the presentation video now, in a couple of hours I will be submitting the demo video too
Project name
mental healt aware
Description
The problem we're solving
These days is very common to see people struggling with depression and mental health. The WHO (World Health Organization) said we need to transform mental health, we need to be more aware of our current mental state and be willing to take a break.
The solution?
Create a WebAPI to access the user's calendar and manage the coming events and reschedule if needed so he/she can take a small or long break.
Features
Repo URL
https://github.com/felipeschneider88/mental-health-aware
Team members
felipeschneider88