protected async override void OnActivated(IActivatedEventArgs args) { var continuationEventArgs = args as IContinuationActivatedEventArgs; if (continuationEventArgs != null) { if (continuationEventArgs.ContinuationData != null) { if (args is WebAuthenticationBrokerContinuationEventArgs) { WebAuthenticationBrokerContinuationEventArgs webargs = args as WebAuthenticationBrokerContinuationEventArgs; //await NavigationService.Current.RequestFlickrAuthorizationComplete( // webargs.WebAuthenticationResult.ResponseStatus, // webargs.WebAuthenticationResult.ResponseData, // webargs.WebAuthenticationResult.ResponseErrorDetail // ); var operation = continuationEventArgs.ContinuationData["Operation"]; //NavigationService.Current.Navigate((eViews)Enum.Parse(typeof(eViews), (string)operation)); } } ////ContinuationManager.Continue(continuationEventArgs); } Window.Current.Activate(); }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { if (args != null) { ObjFBHelper.ContinueAuthentication(args); } if (ObjFBHelper.AccessToken != null) { fbclient = new FacebookClient(ObjFBHelper.AccessToken); dynamic parameters = new ExpandoObject(); parameters.access_token = ObjFBHelper.AccessToken; parameters.fields = "id,name,email"; //Fetch facebook UserProfile: dynamic profileDetails = await fbclient.GetTaskAsync("me", parameters); string id = profileDetails.id; string email = profileDetails.email; string name = profileDetails.name; string profilePicture = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", id, "large", ObjFBHelper.AccessToken); LoginWithFacebook(id, email, name, profilePicture); } }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { ObjFBHelper.ContinueAuthentication(args); if (ObjFBHelper.AccessToken != null) { IsolatedStorageHelper.SaveObject <String>("2", ObjFBHelper.AccessToken); fbclient = new Facebook.FacebookClient(ObjFBHelper.AccessToken); //Fetch facebook UserProfile: dynamic result = await fbclient.GetTaskAsync("me"); id = result.id; string email = result.email; FBName = result.name; Debug.WriteLine("sssssssss"); Debug.WriteLine(id); Debug.WriteLine(FBName); //Format UserProfile: GetUserProfilePicture(id); BtnLogin.Visibility = Visibility.Collapsed; BtnLogout.Visibility = Visibility.Visible; TFname.Text = FBName; IsolatedStorageHelper.SaveObject("1", id); } else { String message = "No Internet Connection"; var dialog = new MessageDialog(message); await dialog.ShowAsync(); } }
internal static async Task ContinueAcquireTokenAsync(WebAuthenticationBrokerContinuationEventArgs args) { _authenticationResult = await _authenticationContext.ContinueAcquireTokenAsync(args); // TODO by app developer: ideally we want to preserve the state of what we wanted to do before the continuation call, and do it. // see https://msdn.microsoft.com/library/windows/apps/dn631755.aspx and http://www.cloudidentity.com/blog/2014/06/16/adal-for-windows-phone-8-1-deep-dive/ }
/* * Signature base string * POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&oauth_consumer_key%3DLK2akZl6e6BMEAPDMxGueajSp%26oauth_nonce%3D768ae59f0653f5b289fe5305c1a55033%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1405193441%26oauth_token%3D15244042-LXQPX5ILb2TpOvXc5gBgXsIFvMQo9Zvw0DyA7i2ve%26oauth_version%3D1.0%26status%3DMaybe%2520he%2527ll%2520finally%2520find%2520his%2520keys.%2520%2523peterfalk * * Authorization header * Authorization: OAuth oauth_consumer_key="LK2akZl6e6BMEAPDMxGueajSp", oauth_nonce="768ae59f0653f5b289fe5305c1a55033", oauth_signature="2VcjU41Ce7LaSHTW3iWjv%2FvLKhE%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1405193441", oauth_token="15244042-LXQPX5ILb2TpOvXc5gBgXsIFvMQo9Zvw0DyA7i2ve", oauth_version="1.0" * * */ // http://d.hatena.ne.jp/kaorun/20140518/1400392292 // http://peterfoot.net/2014/04/14/webauthenticationbroker-wp8/ // http://blogs.msdn.com/b/wsdevsol/archive/2014/05/08/using-the-andcontinue-methods-in-windows-phone-silverlight-8-1-apps.aspx // http://msdn.microsoft.com/ja-jp/library/dn631755.aspx // http://msdn.microsoft.com/ja-jp/library/dn596094.aspx public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult result = args.WebAuthenticationResult; // Process the authentication result switch (result.ResponseStatus) { case WebAuthenticationStatus.Success: { var response = result.ResponseData.ToString(); this.oauthVerifier = twitterOAuth.ParseRedirectToAuthResponse(response); this.GetAccessTokenButton.IsEnabled = true; this.WriteLog(String.Format("OAuthVerifier:{0}", this.oauthVerifier.OAuthVerifier)); break; } case WebAuthenticationStatus.UserCancel: break; case WebAuthenticationStatus.ErrorHttp: { var response = result.ResponseErrorDetail.ToString(); this.WriteLog(String.Format("Error:ContinueWebAuthentication:{0}", response)); break; } default: break; } }
// This method is automatically invoked when the application is reactivated after an authentication interaction through WebAuthenticationBroker. // In order to make this method work as expected, you need to create a ContinuationManager object in App.xaml.cs. // See http://www.cloudidentity.com/blog/2014/08/28/use-adal-to-connect-your-universal-apps-to-azure-ad-or-adfs/ for // more information. public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { // Pass the authentication interaction results to ADAL, which will conclude the token acquisition operation and invoke the callback specified in AcquireTokenAndContinue (in AuthenticationHelper). AuthenticationResult result = await AuthenticationHelper.AuthenticationContext.ContinueAcquireTokenAsync(args); if (result.Status == AuthenticationStatus.Success) { Debug.WriteLine("User authenticated successfully."); // Store authentication details for silent authentication next time. App._settings.TenantId = result.TenantId; App._settings.LastAuthority = AuthenticationHelper.AuthenticationContext.Authority; App._settings.UserEmail = result.UserInfo.DisplayableId; // Hide "Connect to Office 365" button. _viewModel.ShowConnectUI = false; _viewModel.ShowMailUI = true; _viewModel.ShowAppBar = true; // Now that user has authenticated, get emails to display. _viewModel.GetMessages(); } else { Debug.WriteLine(result.ErrorDescription); } }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { ObjFBHelper.ContinueAuthentication(args); if (ObjFBHelper.AccessToken != null) { fbclient = new Facebook.FacebookClient(ObjFBHelper.AccessToken); //Fetch facebook UserProfile: dynamic result = await fbclient.GetTaskAsync("me"); string id = result.id; string email = result.email; string FBName = result.name; //Format UserProfile: GetUserProfilePicture(id); TxtUserProfile.Text = FBName; StckPnlProfile_Layout.Visibility = Visibility.Visible; BtnLogin.Visibility = Visibility.Collapsed; BtnLogout.Visibility = Visibility.Visible; } else { StckPnlProfile_Layout.Visibility = Visibility.Collapsed; } }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { ObjFBHelper.ContinueAuthentication(args); if (ObjFBHelper.AccessToken != null) { fbclient = new Facebook.FacebookClient(ObjFBHelper.AccessToken); //Fetch facebook UserProfile: dynamic result = await fbclient.GetTaskAsync("me"); string id = result.id; string email = result.email; string FBName = result.name; IsLoggedIn = true; btnFBLogin.Content = "Log out"; txtBlockContent.Text = "You're now logged in as " + FBName; var msgDialog = new MessageDialog("Hello, " + FBName, "Login successful"); await msgDialog.ShowAsync(); } else { var msgDialog = new MessageDialog("Check your credentials and try again", "Login failed"); await msgDialog.ShowAsync(); } }
// IWebAuthenticationContinuable public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { if (UserData.Provider == AuthProvider.MicrosoftOffice365) { await O365Auth.ContinueAcquireTokenAsync(args); } }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { var result = args.WebAuthenticationResult; switch (result.ResponseStatus) { case WebAuthenticationStatus.Success: var response = new AuthorizeResponse(args.WebAuthenticationResult.ResponseData); var identity = new Identity(); identity.AddClaims(new Claim(Claim.AccessTokenName, response.AccessToken)); identity.ExtractFromIdentityToken(response.IdentityToken); var authService = ServiceLocator.Current.GetInstance <IAuthenticationService>(); await authService.StoreAndUpdateIdentityAsync(identity).ConfigureAwait(false); break; default: await _dialogService.ShowError(Loc.GetLocalizedString(Localized.AuthenticationError), null, null, null) .ConfigureAwait(false); return; } }
/// <summary> /// Continues the app after retrieving the authorization code. /// /// First it stores the authorization code result in the data store. /// Then it calls the view model get blogs method, in order to retrieve all blogs. /// The view model is responsible to check for if the authorization code exists in the data store, and then, /// continue with the regular flow. /// After retrieving all blogs, this method deletes the authorization code so it won't be used in a next run. /// </summary> public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { await PasswordVaultDataStore.Default.StoreAsync<SerializableWebAuthResult>( SerializableWebAuthResult.Name, new SerializableWebAuthResult(args.WebAuthenticationResult)); await ((BlogsViewModel)this.DataContext).GetBlogsAsync(); await PasswordVaultDataStore.Default.DeleteAsync<SerializableWebAuthResult>( SerializableWebAuthResult.Name); }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { await this.context.ContinueAcquireTokenAsync(args); StorageFolder localFolder = ApplicationData.Current.LocalFolder; await this.fls.CloseAndSaveToFileAsync(); StorageFile logfile = await this.ls.SaveToFileAsync(localFolder, "logfile"); this.AccessToken.Text = logfile.DisplayName; }
/// <summary> /// Continues the app after retrieving the authorization code. /// /// First it stores the authorization code result in the data store. /// Then it calls the view model get blogs method, in order to retrieve all blogs. /// The view model is responsible to check for if the authorization code exists in the data store, and then, /// continue with the regular flow. /// After retrieving all blogs, this method deletes the authorization code so it won't be used in a next run. /// </summary> public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { await PasswordVaultDataStore.Default.StoreAsync <SerializableWebAuthResult>( SerializableWebAuthResult.Name, new SerializableWebAuthResult(args.WebAuthenticationResult)); await((BlogsViewModel)this.DataContext).GetBlogsAsync(); await PasswordVaultDataStore.Default.DeleteAsync <SerializableWebAuthResult>( SerializableWebAuthResult.Name); }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { await this.context.ContinueAcquireTokenAsync(args); StorageFolder localFolder = ApplicationData.Current.LocalFolder; await this.fls.CloseAndSaveToFileAsync(); StorageFile logfile = await this.ls.SaveToFileAsync(localFolder, "logfile"); this.AccessToken.Text = logfile.DisplayName; }
public async void ContinueWebAuthentication( WebAuthenticationBrokerContinuationEventArgs args) { await PasswordVaultDataStore.Default.StoreAsync<SerializableWebAuthResult>( SerializableWebAuthResult.Name, new SerializableWebAuthResult(args.WebAuthenticationResult)); await GetInfo(); await PasswordVaultDataStore.Default.DeleteAsync<SerializableWebAuthResult>( SerializableWebAuthResult.Name); }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { var webResult = args.WebAuthenticationResult; if (webResult.ResponseStatus == WebAuthenticationStatus.Success) { Uri responseUri = new Uri(webResult.ResponseData.ToString()); if (!responseUri.Query.Contains("error=")) { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.Resolve <IAuthHelper>().EndLoginFlow(SalesforceConfig.LoginOptions, authResponse); } } }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { try { WebAuthenticationResult result = args.WebAuthenticationResult; var tcs = _tcs; _tcs = null; tcs.SetResult(DecodeParameters(new Uri(result.ResponseData))); } catch (Exception ex) { throw (ex); } }
///<summary> ///extract access token from fb authentication ///</summary> public static async Task getToken(WebAuthenticationBrokerContinuationEventArgs args) { Exception exception = null; try { var resulturl = args.WebAuthenticationResult; string responseData = resulturl.ResponseData.Substring(resulturl.ResponseData.IndexOf("access_token", StringComparison.Ordinal)); string[] keyValPairs = responseData.Split('&'); for (int i = 0; i < keyValPairs.Length; i++) { string[] splits = keyValPairs[i].Split('='); switch (splits[0]) { case "access_token": accessToken = splits[1]; break; } } try { await AuthenticateUserWithMobileService(); } catch (MobileServiceInvalidOperationException ex) { // await new MessageDialog(ex.Message, "Could not connect to server").ShowAsync(); System.Diagnostics.Debug.WriteLine(ex.Message, "Could Auth"); } try { await AddFacebookUser(accessToken); } catch (MobileServiceInvalidOperationException ex) { // await new MessageDialog(ex.Message, "Could not connect to server").ShowAsync(); System.Diagnostics.Debug.WriteLine(ex.Message, "Could AddFacebookUser"); } } catch (Exception e) { exception = e; } }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { try { WebAuthenticationResult result = args.WebAuthenticationResult; var tcs = _tcs; _tcs = null; tcs.SetResult(DecodeParameters(new Uri(result.ResponseData))); } catch (Exception ex) { throw (ex); } }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { ObjFBHelper.ContinueAuthentication(args); if (ObjFBHelper.AccessToken != null) { fbclient = new Facebook.FacebookClient(ObjFBHelper.AccessToken); //Fetch facebook UserProfile: dynamic result = await fbclient.GetTaskAsync("me"); string id = result.id; string email = result.email; string FBName = result.name; string profilePictureUrl = string.Format("https://graph.facebook.com/{0}/picture?type={1}&access_token={2}", id, "square", ObjFBHelper.AccessToken); // picProfile.Source = new BitmapImage(new Uri(profilePictureUrl)); var bitmap = new BitmapImage(new Uri(profilePictureUrl)); //Format UserProfile: // GetUserProfilePicture(id); // s= FBName; var fbuser = new FbUser() { FbNom = FBName, ProfilePic = bitmap }; SharedInformtionFbUser.sharedUser = fbuser; var rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(AccLoved)); } else { var bitmap = new BitmapImage(new Uri("ms-appx:///Assets/Icons/guestImage.png")); var fbuser = new FbUser() { FbNom = "guest", ProfilePic = bitmap }; SharedInformtionFbUser.sharedUser = fbuser; var rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(MoodCoice)); } }
public async Task<Session> Finalize(WebAuthenticationBrokerContinuationEventArgs args) { Exception exception = null; try { return await GetSession(args.WebAuthenticationResult); } catch (Exception e) { exception = e; } await _logManager.LogAsync(exception); return null; }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { string access_token = null; try { WebAuthenticationResult WebAuthResult = args.WebAuthenticationResult; if (WebAuthResult.ResponseStatus == WebAuthenticationStatus.Success) { string responseData = WebAuthResult.ResponseData.ToString(); string subResponseData = responseData.Substring(responseData.IndexOf("access_token")); String[] keyValPairs = subResponseData.Split('&'); string token_type = null; for (int i = 0; i < keyValPairs.Length; i++) { String[] splits = keyValPairs[i].Split('='); switch (splits[0]) { case "access_token": access_token = splits[1]; //you may want to store access_token for further use. Look at Scenario 5 (Account Management). break; case "token_type": token_type = splits[1]; break; } } ApplicationData.Current.LocalSettings.Values["Tokens"] = access_token; tokenflag = true; storeTokenAndNavigate(); } else if (WebAuthResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { Debug.WriteLine("HTTP Error Response Detail : " + WebAuthResult.ResponseErrorDetail.ToString()); } else { Debug.WriteLine("Error Response Status : " + WebAuthResult.ResponseStatus.ToString()); } } catch (Exception ex) { tokenflag = true; } }
// This method is automatically invoked when the application is reactivated after an authentication interaction through WebAuthenticationBroker. // In order to make this method work as expected, you need to create a ContinuationManager object in App.xaml.cs. // See http://www.cloudidentity.com/blog/2014/08/28/use-adal-to-connect-your-universal-apps-to-azure-ad-or-adfs/ for // more information. public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { var rl = ResourceLoader.GetForCurrentView(); WelcomeText.Text = "acquiring token..."; // pass the authentication interaction results to ADAL, which will conclude the token acquisition operation and invoke the callback specified in AcquireTokenAndContinue (in AuthenticationHelper). AuthenticationResult result = await AuthenticationHelper._authenticationContext.ContinueAcquireTokenAsync(args); if (result.Status == AuthenticationStatus.Success) { PopulateCurrentUserInformation(result); } else { WelcomeText.Text = rl.GetString("AuthenticationErrorMessage"); } }
/// <summary> /// Retrieve token to use Gitter Api methods that requires a connected user /// </summary> /// <param name="args">Args when the Continuation is over, using WebAuthenticationBroker</param> /// <returns>The token</returns> public async Task <string> RetrieveTokenAsync(WebAuthenticationBrokerContinuationEventArgs args) { try { return(await AuthHelper.RetrieveToken(args.WebAuthenticationResult, _oauthKey, _oauthSecret)); } catch { } finally { _oauthKey = string.Empty; _oauthSecret = string.Empty; } return(null); }
/// <summary> /// Retrieve token to use Gitter Api methods that requires a connected user /// </summary> /// <param name="args">Args when the Continuation is over, using WebAuthenticationBroker</param> /// <returns>The token</returns> public async Task<string> RetrieveTokenAsync(WebAuthenticationBrokerContinuationEventArgs args) { try { return await AuthHelper.RetrieveToken(args.WebAuthenticationResult, _oauthKey, _oauthSecret); } catch { } finally { _oauthKey = string.Empty; _oauthSecret = string.Empty; } return null; }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult result = args.WebAuthenticationResult; if (result.ResponseStatus == WebAuthenticationStatus.Success) { OutputToken(result.ResponseData.ToString()); } else if (result.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { OutputToken("HTTP Error returned by AuthenticateAsync() : " + result.ResponseErrorDetail.ToString()); } else { OutputToken("Error returned by AuthenticateAsync() : " + result.ResponseStatus.ToString()); } }
/// <summary> /// The continue web authentication. /// </summary> /// <param name="args"> /// The args. /// </param> public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult result = args.WebAuthenticationResult; if (result.ResponseStatus == WebAuthenticationStatus.Success) { Debug.WriteLine(result.ResponseData); await GetAccessToken(result.ResponseData); } else if (result.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { Debug.WriteLine("HTTP Error : " + result.ResponseErrorDetail); } else { Debug.WriteLine("Error : " + result.ResponseStatus); } }
// This method is automatically invoked when the application is reactivated after an authentication interaction through WebAuthenticationBroker. // In order to make this method work as expected, you need to create a ContinuationManager object in App.xaml.cs. // See http://www.cloudidentity.com/blog/2014/08/28/use-adal-to-connect-your-universal-apps-to-azure-ad-or-adfs/ for // more information. public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { var rl = ResourceLoader.GetForCurrentView(); WelcomeText.Text = "acquiring token..."; // pass the authentication interaction results to ADAL, which will conclude the token acquisition operation and invoke the callback specified in AcquireTokenAndContinue (in AuthenticationHelper). AuthenticationResult result = await AuthenticationHelper._authenticationContext.ContinueAcquireTokenAsync(args); if (result.Status == AuthenticationStatus.Success) { PopulateCurrentUserInformation(result); } else { WelcomeText.Text = rl.GetString("AuthenticationErrorMessage"); } }
/// <summary> /// The continue web authentication. /// </summary> /// <param name="args"> /// The args. /// </param> public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult result = args.WebAuthenticationResult; if (result.ResponseStatus == WebAuthenticationStatus.Success) { Debug.WriteLine(result.ResponseData); await GetAccessToken(result.ResponseData); } else if (result.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { Debug.WriteLine("HTTP Error : " + result.ResponseErrorDetail); } else { Debug.WriteLine("Error : " + result.ResponseStatus); } }
public async Task ExtractCode(WebAuthenticationBrokerContinuationEventArgs args) { if (args.WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { IDictionary <string, string> queryParams = ParseQueryString(new Uri(args.WebAuthenticationResult.ResponseData).Query); if (queryParams.ContainsKey("code")) { await ExchangeAuthorizationCodeForAccessToken(queryParams["code"]); } else { throw new Exception("no code parameter found in redirect"); } } else { throw new Exception(string.Format("user cancelled the authorization status: '{0}': details: {1}", args.WebAuthenticationResult.ResponseStatus, args.WebAuthenticationResult.ResponseErrorDetail)); } }
/// <summary> /// This will fire after login process ContinueWithWebAuthentication /// </summary> /// <param name="args"></param> public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { ObjFBHelper.ContinueAuthentication(args); if (ObjFBHelper.AccessToken != null) { GlobalVariable.fbclient = new Facebook.FacebookClient(ObjFBHelper.AccessToken); GlobalVariable.FbAccessToken = ObjFBHelper.AccessToken; StckPnlProfile_Layout.Visibility = Visibility.Visible; BtnLogin.Visibility = Visibility.Collapsed; BtnLogout.Visibility = Visibility.Visible; UserProfile oUserProfile = await GlobalVariable.oTSGFacebookManager.GetUserProfile(); if (oUserProfile != null) { TxtUserProfile.Text = oUserProfile.Name; picProfile.Source = new BitmapImage(new Uri(oUserProfile.ImageURL)); } } else { } }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs ex) { var oauthClient = new ClientOAuth(); oauthClient.LoginCallback += (isSucces, err, response) => { if (isSucces) { // TODO: deal the OAuth result. Frame frame = new Frame(); frame = Window.Current.Content as Frame; frame.Navigate(typeof(GoodNightPage)); } else { // TODO: handle the err. Frame frame = new Frame(); frame = Window.Current.Content as Frame; frame.Navigate(typeof(LoginPage)); } }; oauthClient.continueAuth(ex.WebAuthenticationResult); }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult webResult = args.WebAuthenticationResult; var logMsg = String.Format("AccountPage.ContinueWebAuthentication - WebAuthenticationResult: Status={0}", webResult.ResponseStatus); if (webResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { logMsg += string.Format(", ErrorDetail={0}", webResult.ResponseErrorDetail); } PlatformAdapter.SendToCustomLogger(logMsg, LoggingLevel.Verbose); if (webResult.ResponseStatus == WebAuthenticationStatus.Success) { var responseUri = new Uri(webResult.ResponseData); if (!responseUri.Query.Contains("error=")) { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.Resolve <IAuthHelper>().EndLoginFlow(SalesforceConfig.LoginOptions, authResponse); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_error")); SetupAccountPage(); } } else if (webResult.ResponseStatus == WebAuthenticationStatus.UserCancel) { SetupAccountPage(); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_authentication_error")); SetupAccountPage(); } }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { App.ObjFBHelper.ContinueAuthentication(args); if (App.ObjFBHelper.AccessToken != null) { fbclient = new Facebook.FacebookClient(App.ObjFBHelper.AccessToken); //Fetch facebook UserProfile: dynamic result = await fbclient.GetTaskAsync("me"); string id = result.id; string email = result.email; string FBName = result.name; //Format UserProfile: GetUserProfilePicture(id); TxtUserProfile.Text = FBName; ProfileHelpers.ProfileName = FBName; ProfileHelpers.IsLogin = true; // Login finish // Sync infomation var challenge = App.MyWakeOrWasteBL.GetMyChallenge(); //StckPnlProfile_Layout.Visibility = Visibility.Visible; //BtnLogin.Visibility = Visibility.Collapsed; //BtnLogout.Visibility = Visibility.Visible; Frame.GoBack(); } else { // StckPnlProfile_Layout.Visibility = Visibility.Collapsed; } }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { App.ObjFBHelper.ContinueAuthentication(args); if (App.ObjFBHelper.AccessToken != null) { fbclient = new Facebook.FacebookClient(App.ObjFBHelper.AccessToken); //Fetch facebook UserProfile: dynamic result = await fbclient.GetTaskAsync("me"); string id = result.id; string email = result.email; string FBName = result.name; //Format UserProfile: GetUserProfilePicture(id); TxtUserProfile.Text = FBName; ProfileHelpers.ProfileName = FBName; ProfileHelpers.IsLogin = true; // Login finish // Sync infomation var challenge = App.MyWakeOrWasteBL.GetMyChallenge(); //StckPnlProfile_Layout.Visibility = Visibility.Visible; //BtnLogin.Visibility = Visibility.Collapsed; //BtnLogout.Visibility = Visibility.Visible; Frame.GoBack(); } else { // StckPnlProfile_Layout.Visibility = Visibility.Collapsed; } }
// This method is automatically invoked when the application is reactivated after an authentication interaction through WebAuthenticationBroker. // In order to make this method work as expected, you need to create a ContinuationManager object in App.xaml.cs. // See http://www.cloudidentity.com/blog/2014/08/28/use-adal-to-connect-your-universal-apps-to-azure-ad-or-adfs/ for // more information. public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { // Pass the authentication interaction results to ADAL, which will conclude the token acquisition operation and invoke the callback specified in AcquireTokenAndContinue (in AuthenticationHelper). AuthenticationResult result = await AuthenticationHelper.AuthenticationContext.ContinueAcquireTokenAsync(args); if (result.Status == AuthenticationStatus.Success) { Debug.WriteLine("User authenticated successfully."); // Store authentication details for silent authentication next time. App._settings.TenantId = result.TenantId; App._settings.LastAuthority = AuthenticationHelper.AuthenticationContext.Authority; App._settings.UserEmail = result.UserInfo.DisplayableId; // Hide "Connect to Office 365" button. _viewModel.ShowConnectUI = false; _viewModel.ShowMailUI = true; _viewModel.ShowAppBar = true; // Now that user has authenticated, get emails to display. _viewModel.GetMessages(); } else { Debug.WriteLine(result.ErrorDescription); } }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { var webResult = args.WebAuthenticationResult; if (webResult.ResponseStatus == WebAuthenticationStatus.Success) { Uri responseUri = new Uri(webResult.ResponseData.ToString()); if (!responseUri.Query.Contains("error=")) { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.Resolve<IAuthHelper>().EndLoginFlow(SalesforceConfig.LoginOptions, authResponse); } } }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { }
// This method is automatically invoked when the application is reactivated after an authentication interaction throuhg WebAuthenticationBroker. public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { // pass the authentication interaction results to ADAL, which will conclude the token acquisition operation and invoke the callback specified in AcquireTokenAndContinue. await authContext.ContinueAcquireTokenAsync(args); }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { try { await StravaLoginHelper.StravaAuth.ContinueGettingTokenWithTempCodeAsync(args.WebAuthenticationResult.ResponseData); } catch (Exception ex) { Debug.WriteLine(ex.Message); } var dialog = new MessageDialog("login sucessfull. Token: " + StravaLoginHelper.StravaAuth.AccessToken); dialog.ShowAsync(); CheckLoggedIn(); }
internal static async Task ContinueAcquireTokenAsync(WebAuthenticationBrokerContinuationEventArgs args) { _authenticationResult = await _authenticationContext.ContinueAcquireTokenAsync(args); // TODO by app developer: ideally we want to preserve the state of what we wanted to do before the continuation call, and do it. // see https://msdn.microsoft.com/library/windows/apps/dn631755.aspx and http://www.cloudidentity.com/blog/2014/06/16/adal-for-windows-phone-8-1-deep-dive/ }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult result = args.WebAuthenticationResult; if (result.ResponseStatus == WebAuthenticationStatus.Success) { OutputToken(result.ResponseData.ToString()); await GetOAuthToken(result.ResponseData.ToString()); } else if (result.ResponseStatus == WebAuthenticationStatus.ErrorHttp) { OutputToken("HTTP Error returned by AuthenticateAsync() : " + result.ResponseErrorDetail.ToString()); } else { OutputToken("Error returned by AuthenticateAsync() : " + result.ResponseStatus.ToString()); } }
public async void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { ProgressOn = true; ObjFBHelper.ContinueAuthentication(args); if (ObjFBHelper.AccessToken != null) { fbclient = new FacebookClient(ObjFBHelper.AccessToken); Singleton.Singleton.Instance().MyFacebookClient = new FacebookClient(ObjFBHelper.AccessToken); dynamic result = await fbclient.GetTaskAsync("me"); string id = result.id; var connecionSocial = new HttpRequestPost(); var getKey = new HttpRequestGet(); var key = await getKey.GetSocialToken(id, "facebook") as string; char[] delimiter = {' ', '"', '{', '}'}; var word = key.Split(delimiter); var stringEncrypt = (id + word[4] + "3uNi@rCK$L$om40dNnhX)#jV2$40wwbr_bAK99%E"); var sha256 = EncriptSha256.EncriptStringToSha256(stringEncrypt); await connecionSocial.ConnexionSocial("facebook", sha256, ObjFBHelper.AccessToken, id); var res = connecionSocial.Received; GetUser(res); } }
public async void Finalize(WebAuthenticationBrokerContinuationEventArgs args) { var result = await _sessionService.Finalize(args); if (!result) { await ShowMessage(); } else { _navigationService.Navigate<MainView>(); InProgress = false; } }
/// <summary> /// Finishes the login process initiated by the LoginAsync() call, should be called from the App OnActivated event /// when it is triggered due to the Web Authentication Broker /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="result"> /// Result from the Web Authentication Broker /// </param> /// <returns> /// Logged in mobile user /// </returns> public static void LoginComplete(this IMobileServiceClient client, WebAuthenticationBrokerContinuationEventArgs result) { AuthenticationBroker authBroker = new AuthenticationBroker(); authBroker.AuthenticationComplete(result.WebAuthenticationResult); }
public void ContinueWithWebAuthenticationBroker(WebAuthenticationBrokerContinuationEventArgs args) { _fbm.ContinueAuthentication(args); txtFbToken.Text = _fbm.AccessToken; }
/// <summary> /// Processes the continuation. /// </summary> /// <param name="args">The <see cref="WebAuthenticationBrokerContinuationEventArgs"/> instance containing the event data.</param> public static void ProcessContinuation(WebAuthenticationBrokerContinuationEventArgs args) { var result = args.WebAuthenticationResult; ProcessResult(result); }
public async Task ExtractCode(WebAuthenticationBrokerContinuationEventArgs args) { if (args.WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success) { IDictionary<string, string> queryParams = ParseQueryString(new Uri(args.WebAuthenticationResult.ResponseData).Query); if (queryParams.ContainsKey("code")) { await ExchangeAuthorizationCodeForAccessToken(queryParams["code"]); } else { throw new Exception("no code parameter found in redirect"); } } else { throw new Exception(string.Format("user cancelled the authorization status: '{0}': details: {1}", args.WebAuthenticationResult.ResponseStatus, args.WebAuthenticationResult.ResponseErrorDetail)); } }
/// <summary> /// Finishes the login process initiated by the LoginAsync() call, should be called from the App OnActivated event /// when it is triggered due to the Web Authentication Broker /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="result"> /// Result from the Web Authentication Broker /// </param> /// <returns> /// Logged in mobile user /// </returns> public static void LoginComplete(this IMobileServiceClient client, WebAuthenticationBrokerContinuationEventArgs result) { AuthenticationBroker authBroker = new AuthenticationBroker(); authBroker.AuthenticationComplete(result.WebAuthenticationResult); }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { await this.context.ContinueAcquireTokenAsync(args); }
/// <summary> /// This will validate all the request. /// </summary> /// <param name="args"></param> public void ContinueAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { ValidateAndProccessResult(args.WebAuthenticationResult); }
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { proxy.ContinueWebAuthentication(args); await PerformAuthorizationAsync(); }
public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { WebAuthenticationResult webResult = args.WebAuthenticationResult; var logMsg = String.Format("AccountPage.ContinueWebAuthentication - WebAuthenticationResult: Status={0}", webResult.ResponseStatus); if (webResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp) logMsg += string.Format(", ErrorDetail={0}", webResult.ResponseErrorDetail); PlatformAdapter.SendToCustomLogger(logMsg, LoggingLevel.Verbose); if (webResult.ResponseStatus == WebAuthenticationStatus.Success) { var responseUri = new Uri(webResult.ResponseData); if (!responseUri.Query.Contains("error=")) { AuthResponse authResponse = OAuth2.ParseFragment(responseUri.Fragment.Substring(1)); PlatformAdapter.Resolve<IAuthHelper>().EndLoginFlow(SalesforceConfig.LoginOptions, authResponse); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_error")); SetupAccountPage(); } } else if (webResult.ResponseStatus == WebAuthenticationStatus.UserCancel) { SetupAccountPage(); } else { DisplayErrorDialog(LocalizedStrings.GetString("generic_authentication_error")); SetupAccountPage(); } }
/// <summary> /// Check if the OAuth process was successful, /// retrieve the OAuth response code and swap it for a pair of access & refresh tokens /// </summary> /// <param name="args">The Windows Phone WebAuthenticationBroker arguments from the completed OAuth process</param> /// <returns>True if the data source was authorised and an access token was retrieved</returns> public bool FinalizeAuthorization(WebAuthenticationBrokerContinuationEventArgs args) { mobileService.LoginComplete(args); return(args.WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success); }
/// <summary> /// Processes the continuation. /// </summary> /// <param name="args">The <see cref="WebAuthenticationBrokerContinuationEventArgs"/> instance containing the event data.</param> public static void ProcessContinuation(WebAuthenticationBrokerContinuationEventArgs args) { var result = args.WebAuthenticationResult; ProcessResult(result); }
public static void LoginComplete(WebAuthenticationBrokerContinuationEventArgs args) { //ContosoMoments.App.MobileService.LoginComplete(args); }
/// <summary> /// This method called when user navigate back to appication after ADAL authentication page. /// </summary> /// <param name="args"></param> public void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { // pass the authentication interaction results to ADAL, which will conclude the token acquisition operation and invoke the callback specified in AcquireTokenAndContinue. Util.ContinueWebAuthentication(args); }
async void IWebAuthenticationContinuable.ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { await Upload(await AccountManager.ParseContinuationEvent(args)); }
public async Task<bool> Finalize(WebAuthenticationBrokerContinuationEventArgs args) { Exception exception = null; try { Session session = null; switch (Provider) { case Constants.FacebookProvider: session = await _facebookService.Finalize(args); break; case Constants.GoogleProvider: session = await _googleService.Finalize(args); break; } Save(session); return true; } catch (Exception e) { exception = e; } await _logManager.LogAsync(exception); return false; }
public void ContinueAuthentication(WebAuthenticationBrokerContinuationEventArgs args) { ValidateAndProccessResult(args.WebAuthenticationResult); }