Not receiving Access_Token in Outlook.com oAuth - Microsoft Community


hi,

this first time developing oauth app. have developed google, yahoo , facebook , works well. on other hand outlook giving me lot of trouble.

first opening web browser user consent following url ionic app. works without issue on ios, android , windows platforms.

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?redirect_uri=https://www.[abcd].com/redirect.html&response_type=code&client_id=[client_id]&scope=openid%20email%20offline_access&prompt=login&

authorization code. no problem far

send post request follows .net c# code on server side

https://login.microsoftonline.com/common/oauth2/v2.0/token?code=[above_code]&client_id=client_id]&client_secret=client_secret]&redirect_uri=https://www.abcd.com/redirect.html&grant_type=authorization_code&scope=openid%20email%20offline_access

unfortunately refresh_token , id_token not access_token, token_type, expires_in or else.

tried calling token endpoint again grant_type=refresh_token hoping provide new access_token. same output.

have searched web , people had issue not receiving refresh_token. issue seems not common @ all.

getting authorization code in ionic app built. access_token being retrieved in .net service using webrequest. code below:

  servicepointmanager.defaultconnectionlimit = 1000;

            byte[] buffer = encoding.ascii.getbytes("code=" + code + "&client_id=" + googlewebappclientid + "&client_secret=" + appclientsecret + "&redirect_uri=" + redirecturl + "&grant_type=authorization_code");

            httpwebrequest req = (httpwebrequest)webrequest.create("https://login.microsoftonline.com/common/oauth2/v2.0/token"); 

            req.method = "post";
            req.contenttype = "application/x-www-form-urlencoded";
            req.contentlength = buffer.length;

            stream strm = req.getrequeststream();
            strm.write(buffer, 0, buffer.length);
            strm.close();

            httpwebresponse webresponse = (httpwebresponse)req.getresponse();
            stream responsestream = webresponse.getresponsestream();
            streamreader responsestreamreader = new streamreader(responsestream);
            string result = responsestreamreader.readtoend();

            newtonsoft.json.linq.jobject jobject = newtonsoft.json.linq.jobject.parse(result);

            return jobject;



Office / Outlook / Microsoft Office Programming / Older versions



Comments

Popular posts from this blog

Can't Sign-in to OneDrive - Microsoft Community

Shared mailbox permissions - Microsoft Community

Outlook 2016 for Mac - Multiple Issues, Error 17884 - Microsoft Community