4

I have implemented this simple code as described here ( vs 2010 , webforms)

protected void Page_Load(object sender, EventArgs e)
{
  var openid = new OpenIdRelyingParty();
  var response = openid.GetResponse();

  if (response != null && response.Status == AuthenticationStatus.Authenticated)
  {
    FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false);
  }
}

Click function :

protected void btnGoogle_Click(object sender, ImageClickEventArgs e)
{
  using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
  {
    var request = openid.CreateRequest("https://www.google.com/accounts/o8/id");
    request.RedirectToProvider();
  }
}

Question #1

When I click the login ( via google) it opens this consent screen :

enter image description here

But how come it works ? I thought that I have to create an API key in Google developer console in order to allow people to login. ( like I did here with other app of myne->)

enter image description here

Obviously I didn't create any "localhost" app. so how does it still works ? (again it's a demo I've downloaded from the internet).

Question #2

Once I have a result :

enter image description here

How can I fetch user data ? ( email for example) {the article doesn't mention it}

nb DotNetOpenAuth ver 3.4.6.10357

Royi Namir
  • 144,742
  • 138
  • 468
  • 792
  • In your session are you logged in to your google account 'via the browser'? - "If user logged into Gmail, he is already authenticated and Google will send back response verifying user’s credentials.", "Again we use relying party object, this time to create response. If response is authenticated by Google – we know who user is... it only means that we know ID that Google assigns to this person" – Paul Zahra Jun 09 '14 at 09:17
  • @PaulZahra what about getting the email via this id ? – Royi Namir Jun 09 '14 at 09:53

1 Answers1

0

That line works because it uses openId and not OAuth2. Open id is old school before Oauth2.

You should also be aware of:

Important: Google has deprecated OpenID 2.0 and will shut it down after a migration period. If your app uses OpenID 2.0, the userinfo endpoint, or OAuth 2.0 login (early version), you should migrate your app by the deadlines given in the migration timetable.

Because OpenId has been depreciated and will be shutdown before April 20, 2015 I wouldn't recommend developing with it.

To answer the question that request doesn't require a client id because its opened and not Oauth2 only oauth2 requires a client id.

Recommend: Google APIs Client Library Tutorial: Google Oauth2 C#

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449