May 19 2020 12:59 AM - edited May 20 2020 01:27 AM
I'm trying to get my teams(The teams i have joined) via an ajax call.
Sample below
function getmyTeams() { $.ajax({ method: 'GET', //url: "https://graph.microsoft.com/v1.0/users/user@tenant.onmicrosoft.com", url: "https://graph.microsoft.com/v1.0/me/joinedTeams", headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' }, }).success(function(response) { console.log(response); }).error(function(error) {}); }
This is my request token code which i believe i'm missing something.If i hardcode the token i get from graph explorer it works.Any ideas?
function requestToken() {
$.ajax({
"async": true,
"crossDomain": true,
"url": "https://cors-anywhere.herokuapp.com/https://login.microsoftonline.com/myteanant.onmicrosoft.com/oauth2/v2.0/token", // Pass your tenant name
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"data": {
"grant_type": "client_credentials",
"client_id ": "from azure", //Provide your app id
"client_secret": "from azure", //Provide your secret
"scope ": "https://graph.microsoft.com/.default"
},
success: function(response) {
console.log(response);
token = response.access_token;
//this works if i hardcode a token from graph. But i guess it could expire and how can i refresh it
//token="Token from Graph";
getmyTeams();
},
error: function(error) {
console.log(JSON.stringify(error));
}
})
}
But i'm getting error
GET https://graph.microsoft.com/v1.0/me/joinedTeams 404 (Not Found)
I can also confirm i have setup postman and the above api url works fine and it returns the data i need
Also confirming the access token works with no issues as i can retrieve data when i use this api below
https://graph.microsoft.com/v1.0/users/user@tenant.onmicrosoft.com
to get current users details I have also added this api permissions for graph
Update*
I tried postman again but getting the error below
Any ideas what i'm missing?
Thanks in Advance
May 19 2020 11:29 PM
May 20 2020 08:34 PM
Jul 14 2020 06:30 AM
Oct 15 2020 11:19 PM
@arty0m Sorry for the late reply.
I would have to look at it again and will let you know.
It has been a while i had a look at it
Jun 11 2021 11:21 AM
@naijacoder can you provide me the update on how did you manage to complete. I am able to get the refresh token from the postman and on basis of that i was able to generate new access token. how would i build the application that uses this