コード例 #1
0
        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);
        }
コード例 #3
0
 public static async Task <string> LoginOneTimeAuthorizationAsync(string clientId, string[] scopes, IWin32Window owner = null)
 {
     return(await FormMicrosoftAccountAuth.GetAuthenticationToken(clientId, scopes, OAuthFlow.ImplicitGrant, owner));
 }
コード例 #4
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;
        }