There is a need to capture the outlook calendar events from a SharePoint online site. For that I am using rest API. To capture the events, i have created an application in outlook Dev center. By using this client id, I am able to Authorize the user and get the response authorized code. but I cannot able to get the Access token using that client id,client secret. It throws an "Unauthorized client, The application xxx is not not supported for the API version" error.I also get the same error in Postman API. However i am able to get the calendar events while trying in "oAuth SandBox" (https://oauthplay.azurewebsites.net/) i can able to get the events. I have a content editor in my sharepoint online site to get the Access token. The following is the code i used in content editor,
jQuery.ajax({ url: "//outlook.office365.com/common/oauth2/token", type: "post", headers:{ "Content-Type":"application/x-www-form-urlencoded" }, data: { grant_type: "authorization_code", code: myaccesscode, client_id: myclientID, client_secret: myclientsecret, redirect_uri:"https://myredirecturl" }, success: function(response){ alert(response); } Fail: function(status.err) { alert("Fail"); } });
Thanks in advance.