All Projects → seven1986 → OAuthLogin.AspNetCore

seven1986 / OAuthLogin.AspNetCore

Licence: Apache-2.0 license
第三方平台联合登陆(facebook、微信、微博、QQ、Kakao)

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to OAuthLogin.AspNetCore

OAuthLogin
第三方平台联合登陆(facebook、微信、微博、QQ、Kakao)
Stars: ✭ 57 (+32.56%)
Mutual labels:  oauth2, facebook, login, nuget, weibo, qq, kakao
Socialite
Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.
Stars: ✭ 1,026 (+2286.05%)
Mutual labels:  oauth2, facebook, login, weibo, qq
Socialsdklibrary
提供微博、微信、QQ、Tim、QQ 轻聊版、钉钉的登陆分享功能支持;
Stars: ✭ 399 (+827.91%)
Mutual labels:  login, weibo, qq
Web Oauth App
第三方登录服务 Web OAuth 示例
Stars: ✭ 30 (-30.23%)
Mutual labels:  oauth2, weibo, qq
Sdk3rd
第三方SDK集成库,授权/分享/支付
Stars: ✭ 249 (+479.07%)
Mutual labels:  login, weibo, qq
YHThirdManager
一个快速、简单、易集成、扩展性好的社交化组件。摒弃友盟等三方库,使用原生SDK。支持微信支付、微信分享、微信登录、微信授权、QQ授权、QQ分享、QQ登录、新浪授权、新浪登录、新浪分享、微博评论、微博获取、支付宝支付。极大的减小了包体积;同时加入了自动管理提示框的功能
Stars: ✭ 41 (-4.65%)
Mutual labels:  login, weibo, qq
Oauth
🔗 OAuth 2.0 implementation for various providers in one place.
Stars: ✭ 336 (+681.4%)
Mutual labels:  oauth2, facebook, login
Sns auth
通用第三方登录SDK,支持微信,微信扫码,QQ,微博登录,支付宝登录,Facebook,Line,Twitter,Google
Stars: ✭ 520 (+1109.3%)
Mutual labels:  oauth2, facebook, qq
Assent
Multi-provider framework in Elixir
Stars: ✭ 126 (+193.02%)
Mutual labels:  oauth2, facebook
Loginsrv
JWT login microservice with plugable backends such as OAuth2, Google, Github, htpasswd, osiam, ..
Stars: ✭ 1,835 (+4167.44%)
Mutual labels:  oauth2, login
Supertokens Core
Open source alternative to Auth0 / Firebase Auth / AWS Cognito
Stars: ✭ 2,907 (+6660.47%)
Mutual labels:  oauth2, login
Aura.auth
Provides a unified interface to local and remote authentication systems.
Stars: ✭ 121 (+181.4%)
Mutual labels:  oauth2, login
Auth
Authenticator via oauth2
Stars: ✭ 118 (+174.42%)
Mutual labels:  oauth2, login
Aerogear Ios Oauth2
Client library for OAuth2/OpenID Connect
Stars: ✭ 151 (+251.16%)
Mutual labels:  oauth2, facebook
Hackathon Starter Kit
A Node-Typescript/Express Boilerplate with Authentication(Local, Github, Facebook, Twitter, Google, Dropbox, LinkedIn, Discord, Slack), Authorization, and CRUD functionality + PWA Support!
Stars: ✭ 242 (+462.79%)
Mutual labels:  oauth2, facebook
Loginpass
Login with Google, GitHub, Twitter, Facebook and many other networks.
Stars: ✭ 177 (+311.63%)
Mutual labels:  oauth2, login
Authing
🔥Authing - IDaaS/IAM solution that can Auth to web and mobile applications.
Stars: ✭ 247 (+474.42%)
Mutual labels:  oauth2, login
Pow assent
Multi-provider authentication for your Pow enabled app
Stars: ✭ 236 (+448.84%)
Mutual labels:  oauth2, facebook
fuck-login
提供一些境内境外常见的站点Python登录脚本
Stars: ✭ 40 (-6.98%)
Mutual labels:  login, weibo
union
union login for wechat,weibo,qq,alipay with go
Stars: ✭ 23 (-46.51%)
Mutual labels:  weibo, qq

OAuthLogin.AspNetCore Build status NuGet Join the chat at https://gitter.im/OAuthLogin/OAuthLogin Average time to resolve an issue GitHub license

NuGet downloads (OAuthLogin) NuGet downloads (OAuthLogin.AspNetCore)
NuGet downloads OAuthLogin NuGet downloads OAuthLogin.AspNetCore

Installation

OAuthLogin.AspNetCore is available as a NuGet package. You can install it using the NuGet Package Console window:

PM> Install-Package OAuthLogin.AspNetCore

If you are looking for the ASP.NET version please head to OAuthLogin project.


Usage

第一步:配置appsettings.json文件

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },
  "Credentials": {
    "QQ": {
      "client_id": "",
      "client_secret": ""
    },
    "Wechat": {
      "client_id": "",
      "client_secret": ""
    },
    "Weibo": {
      "client_id": "",
      "client_secret": ""
    },
    "FaceBook": {
      "client_id": "",
      "client_secret": ""
    },
    "KaKao": {
      "client_id": "",
      "client_secret": ""
    }
  },
}

第二步:在Startup.cs配置微博、微信、QQ、facebook、Kakao的client_id、client_secret

 // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
    // for HttpContext
    services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    var Credentials = Configuration.GetSection("Credentials").Get<CredentialsSetting>();

    LoginProvider.UseWeibo(Credentials.Weibo.client_id, Credentials.Weibo.client_secret);

    LoginProvider.UseQQ(Credentials.QQ.client_id, Credentials.QQ.client_secret);

    LoginProvider.UseFaceBook(Credentials.FaceBook.client_id, Credentials.FaceBook.client_secret);

    LoginProvider.UseWechat(Credentials.Wechat.client_id, Credentials.Wechat.client_secret);

    LoginProvider.UseKakao(Credentials.KaKao.client_id); 
}

第三步:添加Controllers/OAuthController.cs

public class OAuthController : Controller
    {
        IHttpContextAccessor _contextAccessor;

        public OAuthController(IHttpContextAccessor
                  contextAccessor) { this._contextAccessor = contextAccessor; }

        public IActionResult QQ()
        {
            var res = new QQ(_contextAccessor).Authorize();

            if (res != null && res.code == 0)
            {
                return RedirectToLogin(new
                {
                    channel = "qq",
                    code = 0,
                    user = new
                    {
                        uid = res.result.Value<string>("openid"),
                        name = res.result.Value<string>("nickname"),
                        img = res.result.Value<string>("figureurl"),
                        token = res.token
                    }
                });
            }

            return View();
        }

        public IActionResult Wechat()
        {
            var res = new Wechat(_contextAccessor).Authorize();

            if (res != null && res.code == 0)
            {
                return RedirectToLogin(new
                {
                    channel = "wechat",
                    code = 0,
                    user = new
                    {
                        uid = res.result.Value<string>("uid"),
                        name = res.result.Value<string>("nickname"),
                        img = res.result.Value<string>("headimgurl"),
                        token = res.token
                    }
                });
            }

            return View();
        }

        public IActionResult Weibo()
        {
            var res = new Weibo(_contextAccessor).Authorize();

            if (res != null && res.code == 0)
            {
                return RedirectToLogin(new
                {
                    channel = "weibo",
                    code = 0,
                    user = new
                    {
                        uid = res.result.Value<string>("idstr"),
                        name = res.result.Value<string>("name"),
                        img = res.result.Value<string>("profile_image_url"),
                        token = res.token
                    }
                });
            }

            return View();
        }

        public IActionResult Facebook()
        {
            var res = new Facebook(_contextAccessor).Authorize();

            if (res != null && res.code == 0)
            {
                return RedirectToLogin(new
                {
                    channel = "facebook",
                    code = 0,
                    user = new
                    {
                        uid = res.result.Value<string>("id"),
                        name = res.result.Value<string>("name"),
                        img = res.result["picture"]["data"].Value<string>("url"),
                        token = res.token
                    }
                });
            }

            return View();
        }

        public IActionResult Kakao()
        {
            var res = new Kakao(_contextAccessor).Authorize();

            if (res != null && res.code == 0)
            {
                return RedirectToLogin(new
                {
                    channel = "kakao",
                    code = 0,
                    user = new
                    {
                        uid = res.result.Value<string>("uid"),
                        name = res.result.Value<string>("nickname"),
                        img = res.result.Value<string>("thumbnail_image"),
                        token = res.token
                    }
                });
            }

            return View();
        }

        RedirectResult RedirectToLogin(object _entity)
        {
            var OAuthResult = JsonConvert.SerializeObject(_entity);

            // 跳转的页面,union参数后面是编码后的用户数据
            var url = "/login?union=" + WebUtility.UrlEncode(OAuthResult);

            return Redirect(url);
        }
    }

第四步:添加5个空页面,页面里不要有代码

1,Views/OAuth/QQ.cshtml

2,Views/OAuth/Facebook.cshtml

3,Views/OAuth/Wechat.cshtml

4,Views/OAuth/Webo.cshtml

5,Views/OAuth/Facebook.cshtml
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].