I'm trying to authenticate my application using Microsoft OAuth 2.0. Application registration is already done.
I'm using a web browser component to make user allow the application to access user's calendars. Then I'm tracking the redirection URLs to extract the authorization code. But the service redirects the application to an error page.
The URLs: (My application navigates user to the first URL containing authentication info)
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_mode=form_post&prompt=login&client_id=c36b4fd4-8b5a-4831-b146-6e4cdac90d0e&scope=https:%2F%2Fgraph.microsoft.com%2Fcalendars.readwrite &response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob
about:blank
https://login.live.com/Me.srf?wa=wsignin1.0&idpflag=direct&wreply=https:%2F%2Flogin.microsoftonline.com
https://login.live.com/oauth20_authorize.srf?response_mode=form_post&prompt=login&client_id=c36b4fd4-8b5a-4831-b146-6e4cdac90d0e&scope=https:%2F%2Fgraph.microsoft.com%2Fcalendars.readwrite &response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&login_hint=altostratous%40outlook.com&ui_locales=en-US&display=page&uaid=1ed5dd7edad547ea9ae42599ecf8028e&issuer=mso&msproxy=1
https://login.live.com/ppsecure/post.srf?response_mode=form_post&prompt=login&client_id=c36b4fd4-8b5a-4831-b146-6e4cdac90d0e&scope=https:%2F%2Fgraph.microsoft.com%2Fcalendars.readwrite &response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&login_hint=altostratous%40outlook.com&ui_locales=en-US&display=page&issuer=mso&msproxy=1&contextid=04C5394112425BED&bk=1466075419&uaid=1ed5dd7edad547ea9ae42599ecf8028e&pid=15216
https://account.live.com/Consent/Update?ru=https://login.live.com/oauth20_authorize.srf%3flc%3d1033%26response_mode%3dform_post%26prompt%3dlogin%26client_id%3dc36b4fd4-8b5a-4831-b146-6e4cdac90d0e%26scope%3dhttps%253A%252F%252Fgraph.microsoft.com%252Fcalendars.readwrite%2520%26response_type%3dcode%26redirect_uri%3durn:ietf:wg:oauth:2.0:oob%26login_hint%3daltostratous%2540outlook.com%26ui_locales%3den-US%26display%3dpage%26issuer%3dmso%26msproxy%3d1%26uaid%3d1ed5dd7edad547ea9ae42599ecf8028e%26pid%3d15216%26mkt%3dEN-US%26scft%3dDevbhujhpkAjAfbj!ZXBlvEp*4p0KUzdBN3n1IHXrQQauBhA50taNhaXBRiw83xqwtX5hxg4gWMoeOwyjHM8Rh7ou9Ho!Zxun*eKSj3YFvrDeYTKWi5Ch!tAwgEuey7KPwCE22PPek0hBJ23YxeB!zqgG8pviIyWCDZED!86SBSE%26contextid%3d04C5394112425BED&mkt=EN-US&uiflavor=web&id=293577&client_id=000000004019AB47&rd=none&scope=calendars.readwrite&cscope=
https://c1.microsoft.com/c.gif?DI=4050&did=1&t=
https://account.live.com/Consent/Update?ru=https://login.live.com/oauth20_authorize.srf%3flc%3d1033%26response_mode%3dform_post%26prompt%3dlogin%26client_id%3dc36b4fd4-8b5a-4831-b146-6e4cdac90d0e%26scope%3dhttps%253A%252F%252Fgraph.microsoft.com%252Fcalendars.readwrite%2520%26response_type%3dcode%26redirect_uri%3durn:ietf:wg:oauth:2.0:oob%26login_hint%3daltostratous%2540outlook.com%26ui_locales%3den-US%26display%3dpage%26issuer%3dmso%26msproxy%3d1%26uaid%3d1ed5dd7edad547ea9ae42599ecf8028e%26pid%3d15216%26mkt%3dEN-US%26scft%3dDevbhujhpkAjAfbj!ZXBlvEp*4p0KUzdBN3n1IHXrQQauBhA50taNhaXBRiw83xqwtX5hxg4gWMoeOwyjHM8Rh7ou9Ho!Zxun*eKSj3YFvrDeYTKWi5Ch!tAwgEuey7KPwCE22PPek0hBJ23YxeB!zqgG8pviIyWCDZED!86SBSE%26contextid%3d04C5394112425BED&mkt=EN-US&uiflavor=web&id=293577&client_id=000000004019AB47&rd=none&scope=calendars.readwrite&cscope=
https://login.live.com/ppsecure/post.srf?lc=1033&response_mode=form_post&prompt=login&client_id=c36b4fd4-8b5a-4831-b146-6e4cdac90d0e&scope=https:%2f%2fgraph.microsoft.com%2fcalendars.readwrite+&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&login_hint=altostratous%40outlook.com&ui_locales=en-US&display=page&issuer=mso&msproxy=1&mkt=EN-US&scft=DevbhujhpkAjAfbj!ZXBlvEp*4p0KUzdBN3n1IHXrQQauBhA50taNhaXBRiw83xqwtX5hxg4gWMoeOwyjHM8Rh7ou9Ho!Zxun*eKSj3YFvrDeYTKWi5Ch!tAwgEuey7KPwCE22PPek0hBJ23YxeB!zqgG8pviIyWCDZED!86SBSE&contextid=04C5394112425BED&bk=1466075521&uaid=1ed5dd7edad547ea9ae42599ecf8028e&pid=15216&fsui=1
The pages:
Then asks the user to allow the application.
At last this error page is shown when user accepts.