Fiyaz Hasan
Fiyaz Hasan

Reputation: 838

Identity Server 4 External Provider Claims Extension

I've identity server 4 configurations in an ASP.NET Core app. Along with opened and profile scope I also want to get the birthday of the logged-in user as claims. I'm having no luck with the following configuration

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
                .AddFacebook(options =>
                {
                    options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
                    options.AppId = "XXX";
                    options.AppSecret = "XXX";
                    options.SaveTokens = true;
                    options.Scope.Add("user_birthday");
                    options.Fields.Add("birthday");
                })

Any idea why this is not working?

OIDC client request configuration

var config = {
    authority: "https://localhost:44330",
    client_id: "ff-client",
    redirect_uri: "https://localhost:5003/callback.html",
    response_type: "id_token token",
    scope:"openid profile gateway identity",
    post_logout_redirect_uri: "https://localhost:5003/index.html",
    acr_values: "idp:Facebook",
    loadUserInfo: true,
};

Upvotes: 0

Views: 283

Answers (1)

nahidf
nahidf

Reputation: 2394

Check if user granted access. ref: https://developers.facebook.com/docs/graph-api/using-graph-api/common-scenarios/#how-to-get-an-access-token

If you want to confirm that the User has granted your app the user_birthday permission, you can perform a GET operation on the /{user-id}/permissions edge. Assuming the User granted the permission, the API response would look like this:

Sample Response

{
  "data": [
    {
      "permission":"user_birthday",
      "status":"granted"
    }
  ]
}

Upvotes: 1

Related Questions