private async void acquireTokenWithClientCredentialButton_Click(object sender, EventArgs e)
 {
     this.accessTokenTextView.Text = string.Empty;
     TokenBroker tokenBroker = new TokenBroker();
     string token = await tokenBroker.GetTokenWithClientCredentialAsync();
     this.accessTokenTextView.Text = token;
 }
 private async void acquireTokenUPButton_Click(object sender, EventArgs e)
 {
     this.accessTokenTextView.Text = string.Empty;
     TokenBroker tokenBroker = new TokenBroker();
     string token = await tokenBroker.GetTokenWithUsernamePasswordAsync();
     this.accessTokenTextView.Text = token;
 }
 private async void acquireTokenInteractiveButton_Click(object sender, EventArgs e)
 {
     this.accessTokenTextView.Text = string.Empty;
     TokenBroker tokenBroker = new TokenBroker();
     string token = await tokenBroker.GetTokenInteractiveAsync(new PlatformParameters(this));
     this.accessTokenTextView.Text = token;
 }
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            tokenBroker = new TokenBroker();
        }
コード例 #5
0
 private static async Task AcquireTokenAsync()
 {
     TokenBroker tokenBroker = new TokenBroker();
     string token = await tokenBroker.GetTokenInteractiveAsync(new PlatformParameters(PromptBehavior.Auto, null));
     Console.WriteLine(token + "\n");
     token = await tokenBroker.GetTokenWithUsernamePasswordAsync();
     Console.WriteLine(token + "\n");
     token = await tokenBroker.GetTokenWithClientCredentialAsync();
     Console.WriteLine(token);
 }
 async partial void UIButton11_TouchUpInside(UIButton sender)
 {
     try
     {
         ReportLabel.Text = string.Empty;
         TokenBroker tokenBroker = new TokenBroker();
         string token = await tokenBroker.GetTokenInteractiveAsync(new PlatformParameters(this));
         ReportLabel.Text = token;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #7
0
 public static async Task<AuthenticationResult> GetTokenSilentAsync(User user)
 {
     TokenBroker brkr = new TokenBroker();
     PublicClientApplication app =
         new PublicClientApplication("7c7a2f70-caef-45c8-9a6c-091633501de4");
     try
     {
         return await app.AcquireTokenSilentAsync(brkr.Sts.ValidScope);
     }
     catch (Exception ex)
     {
         string msg = ex.Message + "\n" + ex.StackTrace;
         Console.WriteLine(msg);
         return await app.AcquireTokenAsync(brkr.Sts.ValidScope, user.DisplayableId, UiOptions.ActAsCurrentUser, null);
     }
     
 }
        public SecondPage()
        {
            this.tokenBroker = new TokenBroker();

            var browseButton = new Button
            {
                Text = "Acquire Token"
            };

            result = new Label { };
            browseButton.Clicked += browseButton_Clicked;

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    browseButton,
                    result
				}
            };
        }
        private async void acquireTokenSilentButton_Click(object sender, EventArgs e)
        {
            this.accessTokenTextView.Text = string.Empty;
            TokenBroker tokenBroker = new TokenBroker();
            tokenBroker.Sts = sts;
            EditText email = FindViewById<EditText>(Resource.Id.email);
            tokenBroker.Sts.ValidUserName = email.Text;
            string value = null;
            try
            {
                value = await tokenBroker.GetTokenSilentAsync(new PlatformParameters(this)).ConfigureAwait(false);
            }
            catch (Java.Lang.Exception ex)
            {
                throw new Exception(ex.Message + "\n" + ex.StackTrace);
            }
            catch (Exception exc)
            {
                value = exc.Message;
            }

            this.accessTokenTextView.Text = value;

        }
 public MainPage()
 {
     this.InitializeComponent();
     tokenBroker = new TokenBroker();
 }
コード例 #11
0
        public static async Task<AuthenticationResult> GetTokenInteractiveAsync()
        {
            try
            {
                TokenBroker brkr = new TokenBroker();
                PublicClientApplication app =
                    new PublicClientApplication("7c7a2f70-caef-45c8-9a6c-091633501de4");
                await app.AcquireTokenAsync(brkr.Sts.ValidScope);

                return await app.AcquireTokenAsync(brkr.Sts.ValidScope);
            }
            catch (Exception ex)
            {
                string msg = ex.Message + "\n" + ex.StackTrace;
                Console.WriteLine(msg);
            }

            return null;
        }
コード例 #12
0
 private static async Task AcquireTokenAsync()
 {
     TokenBroker app = new TokenBroker();
     string token = await GetTokenIntegratedAuthAsync(app.Sts).ConfigureAwait(false);
     Console.WriteLine(token);
 }
 async partial void UIButton16_TouchUpInside(UIButton sender)
 {
     try
     {
         ReportLabel.Text = string.Empty;
         TokenBroker tokenBroker = new TokenBroker();
         string token = await tokenBroker.GetTokenWithUsernamePasswordAsync();
         ReportLabel.Text = token;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 partial void UIButton30_TouchUpInside(UIButton sender)
 {
     TokenBroker tokenBroker = new TokenBroker();
     tokenBroker.ClearTokenCache();
 }
 async partial void UIButton25_TouchUpInside(UIButton sender)
 {
     try
     {
         ReportLabel.Text = string.Empty;
         TokenBroker tokenBroker = new TokenBroker();
         string token = await tokenBroker.GetTokenWithClientCredentialAsync();
         ReportLabel.Text = token;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        partial void UIButton11_TouchUpInside(UIButton sender)
        {
            try
            {

                ReportLabel.Text = string.Empty;
                TokenBroker tokenBroker = new TokenBroker();
                sts.Authority = "https://login.microsoftonline.com/common";
                sts.ValidClientId = "CLIENT_ID";
                sts.ValidScope = new[] { "SCOPE1" };
                sts.ValidUserName = "******";
                sts.ValidNonExistingRedirectUri = new Uri("APP-SCHEME//BUNDLE-ID");
                tokenBroker.Sts = sts;
                string token = null;// await tokenBroker.GetTokenInteractiveAsync(new PlatformParameters(this));
                ReportLabel.Text = token;
            }
            catch (Exception ex)
            {
                ReportLabel.Text = ex.Message;
            }
        }