waqaskhan540 / identityserver-token-exchange

A solution for exchanging external (Facebook,Google,Twitter etc) tokens with IdentityServer access token.
GNU General Public License v3.0
15 stars 20 forks source link

Make Facebook user fields configurable via custom Provider Store #7

Closed bpred754 closed 5 years ago

bpred754 commented 5 years ago

Currently, the default Facebook fields "gender" and "birthday" require Facebook Review Approval. Since this may not be necessary for some apps, let's make this configurable via a custom Provider Store.

Example:

MyCustomProviders.cs

public static class MyCustomProviders
{
    public static IEnumerable<ExternalTokenExchangeProvider> GetProviders()
    {
        return new List<ExternalTokenExchangeProvider>
        {
            new ExternalTokenExchangeProvider
            {
                Id = 1,
                Fields = "id,email,name",
                Name = "Facebook",
                UserInfoEndpoint = "https://graph.facebook.com/v2.8/me"
            }
        };
    }
}

MyCustomProviderStore.cs

public class MyCustomProviderStore : DefaultTokenExchangeProviderStore
{
    public MyCustomProviderStore () : base(MyCustomProviders.GetProviders()) {}
}

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    services.buildIdentityServer()
        .AddCustomTokenExchangeProviderStore<MyCustomProviderStore>();
}
bpred754 commented 5 years ago

@waqaskhan540, would you mind updating the nuget package as well? Thanks!

waqaskhan540 commented 5 years ago

@bpred754 Yes sure I will and will let you know. Thanks!

bpred754 commented 5 years ago

@waqaskhan540 have you been able to push it yet? I am having to use a custom NuGet feed in the meantime.

bpred754 commented 4 years ago

@waqaskhan540 any update on this?

waqaskhan540 commented 4 years ago

@bpred754 thanks for reminding me and sorry for the late reply, I have just uploaded the updated package to nuget with version 1.0.1, it will be available for download in an hour.

https://www.nuget.org/packages/IdentityServer.External.TokenExchange/1.0.1

bpred754 commented 4 years ago

Awesome, thanks @waqaskhan540!