public static async Task <AppTokenResult> LoginAuthorizationCodeFlowAsync(string clientId, string clientSecret, string[] scopes, IWin32Window owner = null)
        {
            var authorizationCode = await FormMicrosoftAccountAuth.GetAuthenticationToken(clientId, scopes, OAuthFlow.AuthorizationCodeGrant, owner);

            if (string.IsNullOrEmpty(authorizationCode))
            {
                return(null);
            }

            var tokens = await RedeemAuthorizationCodeAsync(clientId, FormMicrosoftAccountAuth.OAuthDesktopEndPoint, clientSecret, authorizationCode);

            return(tokens);
        }
예제 #2
0
        public static async Task <string> GetAuthenticationToken(string clientId, string[] scopes, OAuthFlow flow, IWin32Window owner = null)
        {
            string startUrl, completeUrl;

            GenerateUrlsForOAuth(clientId, scopes, flow, out startUrl, out completeUrl);

            FormMicrosoftAccountAuth authForm = new FormMicrosoftAccountAuth(startUrl, completeUrl, flow);
            DialogResult             result   = await authForm.ShowDialogAsync(owner);

            if (DialogResult.OK == result)
            {
                return(OnAuthComplete(authForm.AuthResult));
            }
            return(null);
        }
 public static async Task <string> LoginOneTimeAuthorizationAsync(string clientId, string[] scopes, IWin32Window owner = null)
 {
     return(await FormMicrosoftAccountAuth.GetAuthenticationToken(clientId, scopes, OAuthFlow.ImplicitGrant, owner));
 }
        public static async Task<string> GetAuthenticationToken(string clientId, string[] scopes, OAuthFlow flow, IWin32Window owner = null)
        {
            string startUrl, completeUrl;
            GenerateUrlsForOAuth(clientId, scopes, flow, out startUrl, out completeUrl);

            FormMicrosoftAccountAuth authForm = new FormMicrosoftAccountAuth(startUrl, completeUrl, flow);
            DialogResult result = await authForm.ShowDialogAsync(owner);
            if (DialogResult.OK == result)
            {
                return OnAuthComplete(authForm.AuthResult);
            }
            return null;
        }