Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Not seeing FacebookOptions.Fields collection? #620

Closed
eriksendc opened this issue Dec 17, 2015 · 6 comments
Closed

Not seeing FacebookOptions.Fields collection? #620

eriksendc opened this issue Dec 17, 2015 · 6 comments

Comments

@eriksendc
Copy link

Hi all,

I'm using ASP.NET 5, MVC 6 RC1 (including Microsoft.AspNet.Authentication.Facebook). When I use the standard, built-in pages for account management, I noticed that when the user selects to authenticate with Facebook, the email field on the /Account/ExternalLoginCallback page is empty. I was just looking at FacebookOptions and there's a Fields property (and in the code there's a link to https://developers.facebook.com/docs/graph-api/reference/user). Anyways, I wanted to play around with adding "email" to my FacebookOptions object's Fields collection, but when I'm in Startup.cs and I declare a FacebookOptions object, it doesn't have a Fields property. When I right-click and go to definition I see this:

// Summary:
//     Configuration options for Microsoft.AspNet.Authentication.Facebook.FacebookMiddleware.
public class FacebookOptions : OAuthOptions
{
    //
    // Summary:
    //     Initializes a new Microsoft.AspNet.Authentication.Facebook.FacebookOptions.
    public FacebookOptions();

    //
    // Summary:
    //     Gets or sets the Facebook-assigned appId.
    public string AppId { get; set; }
    //
    // Summary:
    //     Gets or sets the Facebook-assigned app secret.
    public string AppSecret { get; set; }
    //
    // Summary:
    //     Gets or sets if the appsecret_proof should be generated and sent with Facebook
    //     API calls. This is enabled by default.
    public bool SendAppSecretProof { get; set; }
}

So why does the code in github have a Fields collection on the FacebookOptions object but I'm not seeing that in my application? I've verified my using statements and my project.json has

"Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final"

Thanks in advance,
Brian Eriksen

@kevinchalet
Copy link
Contributor

Hey,

FYI, FacebookOptions.Fields was added recently and is not part of RC1: a18181d. To use it, you need to migrate to the RC2 nightly builds.

That said, you should be able to specify the fields directly in Options.UserInformationEndpoint (e.g Options.UserInformationEndpoint = "https://graph.facebook.com/me?fields=email,timezone,picture";).

@eriksendc
Copy link
Author

Hi there,

Thanks for writing back. The default value of UserInformationEndpoint seems to be just the URL without the query string. I think that the code expects to append the query string itself.

I did find a post that gave me a little direction (http://stackoverflow.com/questions/20378043/getting-the-email-from-external-providers-google-and-facebook-during-account-ass). Adding

facebookOptions.Scope.Add("email");

to Startup.cs seemed to make some progress... Facebook's OAuth page was now acknowledging that my app wanted the user's primary email address. This is what I was really after when I was looking into the Fields collection.

The bummer part is that the standard code in AccountCountroller's ExternalLoginCallback to get the email out of the returned claims isn't working for me:

var info = await _signInManager.GetExternalLoginInfoAsync();
...
var email = info.ExternalPrincipal.FindFirstValue(ClaimTypes.Email);

The value of email is null. Any insights? I did find that my Facebook "app" hadn't yet been switched to "live". I switched it to "live" so that under Approved Items on the Status & Review page in my App's settings in Facebook I now see email as a login permission that is approved.

Thanks,
-Brian

@eriksendc
Copy link
Author

Hi Kevin,
Thanks for the ointer. Can you give me a pointer on how to migrate to the RC2 nightly builds? I'd love to be using the latest and greatest, and then hopefully contribute if I find any bugs. 
Anyways, I've been trying hard to figure out how to get to RC2 easily. I've found https://www.myget.org/gallery/aspnetvnext and I've put https://www.myget.org/F/aspnetvnext/api/v3/index.json in to Visual Studio 2015 as a package source. But when I go through the items in the "dependencies" section in my project.json and do an Install-Package -Pre I often get an error that there are dependencies so it didn't update to ...-rc2-16160. I got rc1-final instead. I've tried ignoring dependencies (using the -IgnoreDependencies flag) but nothing seems to work. Is there something I'm missing? or do I have to put the Install-Package commands in dependency order? Curious as to why the dependencies aren't figuring themselves out.
Thanks in advance.-Brian
From: Kévin Chalet notifications@github.com
To: aspnet/Security Security@noreply.github.com
Cc: eriksendc eriksendc@yahoo.com
Sent: Thursday, December 17, 2015 9:24 AM
Subject: Re: [Security] Not seeing FacebookOptions.Fields collection? (#620)

Hey,FYI, FacebookOptions.Fields was added recently and is not part of RC1: a18181d. To use it, you need to migrate to the RC2 nightly builds.That said, you should be able to specify the fields directly in Options.UserInformationEndpoint (e.g Options.UserInformationEndpoint = "https://graph.facebook.com/me?fields=email,timezone,picture";).—
Reply to this email directly or view it on GitHub.

@Tratcher
Copy link
Member

Open project.json and change rc1-final to *

@eriksendc
Copy link
Author

Hi Chris,
Thanks. Did that and I can build but not run. When IIS Express starts running my web application I get ERR_TOO_MANY_REDIRECTS
Is there anything in global.json that I need to change (like "sdk" "version")?
Thanks,-Brian

  From: Chris R <notifications@github.com>

To: aspnet/Security Security@noreply.github.com
Cc: eriksendc eriksendc@yahoo.com
Sent: Thursday, December 17, 2015 12:48 PM
Subject: Re: [Security] Not seeing FacebookOptions.Fields collection? (#620)

Open project.json and change rc1-final to *—
Reply to this email directly or view it on GitHub.

@Tratcher
Copy link
Member

Yes you should change your sdk version to rc2-something, or just remove it and use the dnvm default. You'll need to use dnvm upgrade -u to install rc2 dnx.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants