Пример #1
0
        /// <summary>
        /// Sign-in to Microsoft Account by asking user to open sign-in page using browser.
        /// </summary>
        /// <remarks>
        /// The downside is this require user to copy and paste lengthy content from and to console.
        /// Sign-in page: 218 chars
        /// Response URL: around 1500 chars
        /// </remarks>
        /// <param name="session"></param>
        /// <returns></returns>
        public static LoginResult MicrosoftBrowserLogin(out SessionToken session, string loginHint = "")
        {
            if (string.IsNullOrEmpty(loginHint))
            {
                Microsoft.OpenBrowser(Microsoft.SignInUrl);
            }
            else
            {
                Microsoft.OpenBrowser(Microsoft.GetSignInUrlWithHint(loginHint));
            }
            ConsoleIO.WriteLine("Your browser should open automatically. If not, open the link below in your browser.");
            ConsoleIO.WriteLine("\n" + Microsoft.SignInUrl + "\n");

            ConsoleIO.WriteLine("Paste your code here");
            string code = ConsoleIO.ReadLine();

            var msaResponse = Microsoft.RequestAccessToken(code);

            return(MicrosoftLogin(msaResponse, out session));
        }
Пример #2
0
        public static LoginResult MicrosoftLoginRefresh(string refreshToken, out SessionToken session)
        {
            var msaResponse = Microsoft.RefreshAccessToken(refreshToken);

            return(MicrosoftLogin(msaResponse, out session));
        }