Authing DocsDocuments
Concept
workflow
Guides
Development Integration
Application integration
Concept
workflow
Guides
Development Integration
Application integration
Old Version
Development Integration
  • Single Sign-On (SSO)
  • Login component

  • JavaScript/Node.js

    • User Authentication Module

      • User authentication module
      • Standard agreement certification module
      • Scan code login module
      • Multi-factor authentication module
      • Social login module
      • Corporate identity source login module
      • Main authentication module
    • Management Module

  • Java / Kotlin

  • Python

  • C#

  • PHP

  • Go

  • Ruby
  • Android

  • iOS

  • Flutter

  • React Native
  • WeChat Mini Program
  • WeChat webpage authorization
  • Framework Integration
  • Error code
  1. Development Integration
  2. /
  3. JavaScript/Node.js
  4. /
  5. User Authentication Module
  6. /
  7. Social login module

¶ SocialAuthenticationClient

Update Time: 2025-02-18 09:00:47
Edit

This module encapsulates the function of social login, and you can quickly use social login to obtain user information through a simple API.

Initiate a social login authorization request:

import { AuthenticationClient } from "authing-js-sdk"
const authenticationClient = new AuthenticationClient({
   appId: "AUTHING_APP_ID",
   appHost: 'https://xxx.authing.cn',
})
await authenticationClient.social.authorize("github", {
   onSuccess: (user) => { console.log(user) },
   onError: (code, message) => {  }
})

¶ Send authorization login request

SocialAuthenticationClient().authorize(provider, options)

Send an authorization login request. This method will directly open a new window and redirect to the login authorization page of a third-party social login service provider (such as GitHub). After the user completes the authorization, this window will be automatically closed. And trigger the onSuccess callback function, from which you can get user information.

¶ Parameters

  • provider <string> The logo of the social login service provider.
  • options <object>
  • options.popup <boolean> Whether to open the social login window through a pop-up window, if set to false, a new browser tab will be opened in the form of window.open. The default value is: true.
  • options.onSuccess <Function> The user agrees to the authorization event callback function. The first parameter is user information.
  • options.onError <Function> The callback function of the social login failure event, the first parameter code is the error code, and the second parameter message is the Error message. For details, please see:Authing error code list.
  • options.position <object> It is valid only when options.popup is true. The position of the pop-up window is { w: 585, h: 649 } by default.

¶ Example

// Log in with GitHub

const authenticationClient = new AuthenticationClient({
   appId: "AUTHING_APP_ID",
   appHost: 'https://xxx.authing.cn',
})

await authenticationClient.social.authorize("github", {
   onSuccess: (user) => { console.log(user) },
   onError: (code, message) => {  },
   // position of the pop-up window
   position: {
     w: 100,
     h: 100
   }
})
// Use the new browser tab to open the social login page

const authenticationClient = new AuthenticationClient({
   appId: "AUTHING_APP_ID",
   appHost: 'https://xxx.authing.cn',
})

await authenticationClient.social.authorize("github", {
   popup: false,
   onSuccess: (user) => { console.log(user) },
   onError: (code, message) => {  },
})

¶ Return value

Prev: Multi-factor authentication module Next: Corporate identity source login module
  • Send authorization login request

User identity management

Integrated third-party login
Mobile phone number flash check (opens new window)
Universal login form component
Custom authentication process

Enterprise internal management

Single Sign On
Multi-factor Authentication
Authority Management

Developers

Development Document
Framework Integration
Blog (opens new window)
GitHub (opens new window)
Community User Center (opens new window)

Company

400 888 2106
sales@authing.cn
16 / F, Block B, NORTH STAR CENTURY CENTER, Beijing(Total)
room 406, 4th floor, zone B, building 1, No. 200, Tianfu Fifth Street, Chengdu(branch)

Beijing ICP No.19051205-1

© Beijing Steamory Technology Co.