/// <summary> /// Google plus authentication event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void GP_OnClick(object sender, EventArgs e) { try { Session["channel"] = Channel.GooglePlus.ToString(); //Retrieve values from settings file var googleConsumerKeySettings = ConfigurationManager.AppSettings["GoogleConsumerKey"]; var googleConsumerSecretSettings = ConfigurationManager.AppSettings["GoogleConsumerSecret"]; var googleRequestTokenUrlSettings = ConfigurationManager.AppSettings["GoogleRequestTokenUrl"]; var googleVerifierUrlSettings = ConfigurationManager.AppSettings["GoogleVerifierUrl"]; var googleRequestAccessTokenUrlSettings = ConfigurationManager.AppSettings["GoogleRequestAccessTokenUrl"]; var googleRequestProfileUrlSettings = ConfigurationManager.AppSettings["GoogleRequestProfileUrl"]; var googleScopeSettings = ConfigurationManager.AppSettings["GoogleScope"]; string googleConsumerKey = string.Empty; string googleConsumerSecret = string.Empty; string googleRequestTokenUrl = string.Empty; string googleVerifierUrl = string.Empty; string googleRequestAccessTokenUrl = string.Empty; string googleRequestProfileUrl = string.Empty; string googleScope = string.Empty; if (googleConsumerKeySettings != null) googleConsumerKey = googleConsumerKeySettings.ToString(); if (googleConsumerSecretSettings != null) googleConsumerSecret = googleConsumerSecretSettings.ToString(); if (googleRequestTokenUrlSettings != null) googleRequestTokenUrl = googleRequestTokenUrlSettings.ToString(); if (googleVerifierUrlSettings != null) googleVerifierUrl = googleVerifierUrlSettings.ToString(); if (googleRequestAccessTokenUrlSettings != null) googleRequestAccessTokenUrl = googleRequestAccessTokenUrlSettings.ToString(); if (googleRequestProfileUrlSettings != null) googleRequestProfileUrl = googleRequestProfileUrlSettings.ToString(); if (googleScopeSettings != null) googleScope = googleScopeSettings.ToString(); //Create Credential object with consumer specific credentials Credentials credential = new Credentials(); credential.ConsumerKey = googleConsumerKey; credential.ConsumerSecret = googleConsumerSecret; credential.RequestTokenUrl = googleRequestTokenUrl; credential.VerifierUrl = googleVerifierUrl; credential.RequestAccessTokenUrl = googleRequestAccessTokenUrl; credential.RequestProfileUrl = googleRequestProfileUrl; credential.Scope = googleScope; var tClient = new OAuthGoogleClient(); tClient.BeginAuthentication(credential); } catch (Exception ex) { txtGPResponse.Text = "Error occurred while retrieving google token! " + ex.Message; } }
protected void google_OnClick(object sender, EventArgs e) { var tClient = new OAuthGoogleClient(); tClient.BeginAuthentication(); }