/LineAuthentication-AspNetCore

It is Line Login Extensions for ASP.NET Core.

Primary LanguageC#Apache License 2.0Apache-2.0

LineAuthentication for ASP.NET Core

LineAuthentication provides LINE authentication like Twitter, Facebook, and other external login. Supports LINE Profile+.

Support Platforms

  • .NET Standard 2.0+
  • .NET Core 3.0+
  • .NET 5+

How to use

It is very easy to use, just call AddLine() which is an extension method of AuthenticationBuilder. This API style is same of other external login, so you never confuse.

services
    .AddAuthentication()
    .AddLine(options =>
    {
        options.ClientId = Configuration["Authentication:Line:ChannelId"];
        options.ClientSecret = Configuration["Authentication:Line:ChannelSecret"];
    });

To access the LINE Profile+, add an authorization scope and extract the data from the JSON payload.

services
    .AddAuthentication()
    .AddLine(options =>
    {
        // ...

        // Add authorization scopes
        options.Scope.Add("real_name");
        options.Scope.Add("gender");
        options.Scope.Add("birthdate");
        options.Scope.Add("address");
        options.Scope.Add("phone");
        options.Scope.Add("email");

        // Map JSON payload to claims
        options.ClaimActions.MapJsonKey(ClaimTypes.Email, "email");

        // Access entire JSON payload
        options.Events.OnCreatingTicket = context =>
        {
            var json = context.User.GetRawText();
            return Task.CompletedTask;
        };
    });

Installation

dotnet add package LineAuthentication

LINE login docs

License

This library is provided under Apache License 2.0.

Authors

Tsubasa Yoshino is software developer in Tokyo, Japan. Awarded Microsoft MVP (Azure) since October, 2016. He's the original owner of this project.

Takaaki Suzuki is software developer in Fukui, Japan. Awarded Microsoft MVP (C#) since July, 2012. He's a contributer who led the .NET Standard / .NET 5 and LINE Profile+ support.