qq api oauth2.0 netnr 2018年01月10日发表

项目地址: https://github.com/netnr/Netnr.Login

接入QQ地址:https://connect.qq.com/manage.html

接入QQ登录需要做哪些事情:

  • 备案域名,公网环境,成熟站点
  • 创建应用,填写网站地址网站回调地址,并得到APP IDAPP Key

接入方式:OAuth2.0

开发流程:

示例

//获取 access_token
var accessToken_ResultEntity = QQ.AccessToken(new QQ_AccessToken_RequestEntity()
{
    code = Request.Query["code"]
});

//获取 OpendId
var openId_ResultEntity = QQ.OpenId(new QQ_OpenId_RequestEntity()
{
    access_token = accessToken_ResultEntity.access_token
});

//获取 UserInfo
var openId_Get_User_Info_ResultEntity = QQ.OpenId_Get_User_Info(new QQ_OpenAPI_RequestEntity()
{
    access_token = accessToken_ResultEntity.access_token,
    openid = openId_ResultEntity.openid
});

//身份唯一标识
string openId = openId_ResultEntity.openid;
if (string.IsNullOrWhiteSpace(openId))
{
    throw new Exception("身份验证失败");
}

留言

ˆ