Authing 知识库
🛠 开发资源🥂 集成案例🔭 常见问题🖥 控制台
3.0.0
3.0.0
  • 欢迎
  • Authing 概述
  • 快速开始
    • 注册 Authing 开发者账号
    • 第一个应用
    • 基础概念
    • 实现单点登录
    • 控制台概览
    • 部署模型和价格
    • 最佳开发实践
    • 我该如何选择 Authing 的技术
  • 进阶指南
    • 理解认证和授权
      • 用户名 - 密码认证
      • 邮箱 - 密码认证
      • 手机 - 验证码认证
      • JWT Token 释义及使用
    • 验证 Token
    • 配置用户权限
    • 迁移老数据进 Authing
    • 错误代码
  • 认证
    • 接入 OAuth 2.0
      • 创建 OAuth 应用
      • 使用 OAuth 授权
    • 接入 OpenID Connect
      • 创建 OIDC 应用
      • 使用 OIDC 授权
      • 理解 OIDC 流程
      • OIDC 常见问题
    • 接入 SAML
      • 创建 SAML Identity Provider 应用
      • 创建 SAML Service Provider 应用
      • 理解 SAML 流程
      • 同时使用 Authing 作为 SP 和 IdP
      • 使用 SAML Identity Provider
        • 在阿里云访问管理中使用
        • 在腾讯云访问管理中使用
        • 在 Auth0 中使用
      • 使用 SAML Service Provider
        • 与 Auth0 SAML IdP 对接
        • 与 SSOCircle SAML IdP 对接
    • 接入 LDAP
      • 配置 LDAP 服务
      • 使用 Authing 的 LDAP 用户目录
    • 接入 Active Directory
  • 社会化登录
    • 接入 Web 端社会化登录
      • GitHub 登录
      • 微信 PC 扫码登录
      • 微信 APP 内网页登录
      • 企业微信(第三方应用)网页授权登录
      • 企业微信(第三方应用)扫码登录
      • 企业微信(企业内部)扫码登录
      • 新浪微博登录
      • 钉钉登录
      • QQ 登录
      • 配置登录授权 Scope
    • 接入移动端社会化登录
      • 微信登录
      • 支付宝登录
    • 接入小程序登录
      • 小程序登录
        • 用户登录凭证(code)最佳实践
      • APP 拉起小程序登录
    • 打通微信账号体系
  • 扫码登录
    • 小程序扫码登录
      • 接入私有化小程序
    • APP 扫码登录
      • 快速接入
      • Web 端 SDK
      • 完整接口列表
      • 自定义配置项
      • 扫码登录原理
  • 移动应用登录
    • 移动应用 SSO
      • 自动检测登录
      • 唤起 App 登录
    • 移动应用身份提供商
  • 授权
    • Authorization 基础概念
      • 什么是基于角色的管理(RBAC)
      • 什么是基于属性的管理(ABAC)
      • 什么是零信任网络
    • Authorization at Authing
    • 接入 RBAC
    • 接入 ABAC
    • 接入组织机构管理
  • 扩展能力
    • 自定义认证流程(Pipeline)
      • 创建你的第一个 Pipeline 函数
      • Pipeline 函数开发指南
      • 应用场景
      • user 对象
      • context 对象
      • 使用环境变量
      • 可用的 Node Modules
      • 如何调试
      • Node SDK
      • GraphQL API
      • 常见问题
      • 私有化部署
    • 使用 Webhook
    • 自定义用户字段
  • 开发资源
    • 开发资源
    • API(GraphQL)
    • Guard for Web
      • 自定义 Guard 的 UI 样式
    • Guard for Mobile
      • Guard for React Native
    • Guard VS 自定义 UI
    • SDK for 单点登录
    • SDK for JavaScript
      • 查询用户权限
      • 绑定社会化登录
      • 自定义用户字段
      • 管理 MFA 口令
      • 自定义请求链接
    • SDK for Node.js
      • 权限控制
      • 查询用户权限
      • 组织机构管理
      • 老版权限控制(deprecated)
      • Pipeline 函数
      • 自定义用户字段
      • 绑定社会化登录
      • 管理 MFA 口令
      • 自定义请求连接
    • SDK for React Native
    • SDK for 微信小程序
    • SDK for Java
    • SDK for Objective-C
    • SDK for Python
    • SDK for Go
    • SDK for PHP
    • 函数计算(FaaS)
  • 通信
    • 邮件
    • SMS
  • MFA
    • 配置 MFA 安全口令
      • 使用 Microsoft Authenticator 添加 MFA 令牌
    • 接入 MFA
  • 安全
    • 配置 Web 安全域
    • 配置用户池密码强度
    • 配置密码加密函数
  • 其他
    • 常见问题
    • 集成案例
      • Authing 与 AWS 集成案例
      • 函数计算与 AaaS 集成案例
      • Odoo 集成案例
      • 社会化登录集成案例
    • 社交互联数据
    • 为 Authing 贡献 SDK
      • 了解 Authing 的模块
Powered by GitBook
On this page
  • 绑定社会化账号
  • 获取用户已经绑定的社会化账号
  • 解绑社会化登录账号

Was this helpful?

  1. 开发资源
  2. SDK for Node.js

绑定社会化登录

绑定社会化账号

Authing.bindOAuth(options)

  • 参数:

    • {Object} options

      • type {String} 必填, 暂时只支持github, wechat

      • unionid {String} 必填,OAuth返回的用户信息中的唯一ID

      • userInfo {String} 必填, JSON.stringfy(OAuth返回的用户信息)

      • user {String} 用户ID,可选,默认为当前登录用户的ID

      • client {String} 应用ID,可选,默认为当前登录应用的ID

  • 使用方法:

    • (async function() {
        const authing = new Authing({
          userPoolId: 'your_userpool_id',
          secret: 'your_userpool_secret'
        });
        const bindResult = await authing.bindOAuth({
          type: 'github',
          unionid: '12345678',
          userInfo: "{"login":"demo","id":12345678,"node_id":"demodemodemo","avatar_url":"https://avatars1.githubusercontent.com/u/19266401?v=4","gravatar_id":"","url":"https://api.github.com/users/demo","html_url":"https://github.com/demo","followers_url":"https://api.github.com/users/demo/followers","following_url":"https://api.github.com/users/demo/following{/other_user}","gists_url":"https://api.github.com/users/demo/gists{/gist_id}","starred_url":"https://api.github.com/users/demo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/demo/subscriptions","organizations_url":"https://api.github.com/users/demo/orgs","repos_url":"https://api.github.com/users/demo/repos","events_url":"https://api.github.com/users/demo/events{/privacy}","received_events_url":"https://api.github.com/users/demo/received_events","type":"User","site_admin":false,"name":"demo","company":null,"blog":"","location":null,"email":"demo@gmail.com","hireable":null,"bio":"A web developer.","public_repos":10,"public_gists":0,"followers":2,"following":3,"created_at":"2016-05-09T12:43:11Z","updated_at":"2018-07-23T04:42:08Z"}"
        });
      })();
  • 返回数据:

    • {
          "_id": "aeolkjhdhfhkkjdsfj",
          "user": "dfdfdsfdsfdsfdsfds",
          "client": "dsfjdskfjkldsjfklj",
          "type": "github",
          "userInfo": "{"login":"demo","id":12345678,"node_id":"demodemodemo","avatar_url":"https://avatars1.githubusercontent.com/u/19266401?v=4","gravatar_id":"","url":"https://api.github.com/users/demo","html_url":"https://github.com/demo","followers_url":"https://api.github.com/users/demo/followers","following_url":"https://api.github.com/users/demo/following{/other_user}","gists_url":"https://api.github.com/users/demo/gists{/gist_id}","starred_url":"https://api.github.com/users/demo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/demo/subscriptions","organizations_url":"https://api.github.com/users/demo/orgs","repos_url":"https://api.github.com/users/demo/repos","events_url":"https://api.github.com/users/demo/events{/privacy}","received_events_url":"https://api.github.com/users/demo/received_events","type":"User","site_admin":false,"name":"demo","company":null,"blog":"","location":null,"email":"demo@gmail.com","hireable":null,"bio":"A web developer.","public_repos":10,"public_gists":0,"followers":2,"following":3,"created_at":"2016-05-09T12:43:11Z","updated_at":"2018-07-23T04:42:08Z"}",
          "unionid": "12345678",
          "createdAt": "2016-05-09T12:43:11Z"
      }

获取用户已经绑定的社会化账号

Authing.readUserOAuthList(options)

  • 参数:

    • {Object} options

      • uesr {String} 用户 ID,可选,默认为当前登录用户的 ID

      • client {String} 应用 ID,可选,默认为当前登录应用的 ID

  • 使用方法:

    • (async function() {
        const authing = new Authing({
          userPoolId: 'your_userpool_id',
          secret: 'your_userpool_secret'
        });
        const userBindedOAuthList = await authing.readUserOAuthList();
      })();
    • 如果 binded 为 true 则代表已经绑定

  • 返回数据:

    • [{
          "type":"github",
          "oAuthUrl":"https://github.com/login/oauth/authorize/?client_id=demo&state=demo",
          "image":"https://usercontents.authing.cn/oauth/logo/github.svg",
          "name":"Github登录",
          "binded":true
      },{
          "type":"wechat",
          "oAuthUrl":"https://open.weixin.qq.com/connect/qrconnect?appid=demo&redirect_uri=demo&response_type=code&scope=snsapi_login&state=demo",
          "image":"https://usercontents.authing.cn/oauth/logo/wechat.png",
          "name":"微信登录",
          "binded":false
      }]

注意事项

暂不支持小程序绑定

解绑社会化登录账号

Authing.unbindOAuth(options)

  • 参数:

    • {Object} options

      • type {String} 必选, 暂时只支持 github, wechat

      • uesr {String} 用户 ID,可选,默认为当前登录用户的 ID

      • client {String} 应用 ID,可选,默认为当前登录应用的 ID

  • 使用方法:

    • (async function() {
        const authing = new Authing({
          userPoolId: 'your_userpool_id',
          secret: 'your_userpool_secret'
        });
        const unbindedResult = await authing.unbindOAuth({
          type: 'github'
        });
      })();
  • 返回数据:

    • {
          "_id": "aeolkjhdhfhkkjdsfj",
          "user": "dfdfdsfdsfdsfdsfds",
          "client": "dsfjdskfjkldsjfklj",
          "type": "github",
          "userInfo": "{"login":"demo","id":12345678,"node_id":"demodemodemo","avatar_url":"https://avatars1.githubusercontent.com/u/19266401?v=4","gravatar_id":"","url":"https://api.github.com/users/demo","html_url":"https://github.com/demo","followers_url":"https://api.github.com/users/demo/followers","following_url":"https://api.github.com/users/demo/following{/other_user}","gists_url":"https://api.github.com/users/demo/gists{/gist_id}","starred_url":"https://api.github.com/users/demo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/demo/subscriptions","organizations_url":"https://api.github.com/users/demo/orgs","repos_url":"https://api.github.com/users/demo/repos","events_url":"https://api.github.com/users/demo/events{/privacy}","received_events_url":"https://api.github.com/users/demo/received_events","type":"User","site_admin":false,"name":"demo","company":null,"blog":"","location":null,"email":"demo@gmail.com","hireable":null,"bio":"A web developer.","public_repos":10,"public_gists":0,"followers":2,"following":3,"created_at":"2016-05-09T12:43:11Z","updated_at":"2018-07-23T04:42:08Z"}",
          "unionid": "12345678",
          "createdAt": "2016-05-09T12:43:11Z"
      }
Previous自定义用户字段Next管理 MFA 口令

Last updated 4 years ago

Was this helpful?

若 binded 为 false , 若按配置, 使用户访问oAuthUrl则可开始OAuth绑定流程

此方法