GenAuth DocsDocuments
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Concepts
User Guide
Development Integration
AgentAuth
Metadata
Development Integration
Multi-tenant (beta)
Console Documentation
Multi-tenant Console
Tenant Console
Saas Application Demo
Old version
Development Integration
  • API

  • SDK

    • Java

      • Installation and use
      • User authentication module

        • Login

          • Account password login
          • Username password login
          • Mobile phone number password login
          • Email password login
          • Login by email verification code
          • Login by mobile phone verification code
          • LDAP account login
          • AD account login
          • Generate login address
          • Login with user credentials
          • Login with mobile social networking
          • Get Alipay AuthInfo
          • Generate a QR code for login
          • Query QR code status
          • Use QR code ticket to exchange for TokenSet
          • Self-built APP scan code login: APP end modifies QR code status
        • Logout

        • Manage Token

        • Register

        • User information

        • Account Binding

        • MFA Factor Management

        • User-related resources

        • Message service

        • Authentication

        • Others

        • OIDC module
        • OAuth module
        • SAML module
        • CAS module
        • Events
      • Management module

    • Node.js

    • Python

  • Error Codes
  1. Development Integration
  2. /
  3. SDK
  4. /
  5. Java
  6. /
  7. User authentication module

  8. /
  9. Login

  10. /
  11. Generate a QR code for login

¶ Generate a QR code for login

Update time: 2025-07-23 07:34:21
Edit

This document is automatically generated based on https://github.com/authing/authing-docs-factory based on https://api-explorer.genauth.ai V3 API, and is consistent with API parameters and return results. If the description of this document is incorrect, please refer to V3 API.

Generate a QR code for login. Currently, it supports the generation of QR codes for WeChat public account scan code login, mini program scan code login, and self-built mobile APP scan code login.

¶ Method Name

AuthenticationClient.geneQrCode

¶ Request Parameters

NameType
Required
Default value
Description
Sample value
typestringYes-QR code type. Currently supports three types:
- MOBILE_APP: Scan the QR code with a self-built mobile APP
- WECHAT_MINIPROGRAM: Scan the QR code with a WeChat applet
- WECHAT_OFFICIAL_ACCOUNT Scan the QR code with a WeChat public account
MOBILE_APP
extIdpConnIdstringNo-When type is WECHAT_MINIPROGRAM or WECHAT_OFFICIAL_ACCOUNT, you can specify the identity source connection, otherwise the first corresponding identity source connection opened by the application is used by default to generate the QR code.62eb7ed1f04xxxxc6955b329
customDataobjectNo-When type is MOBILE_APP, you can pass the user's custom data. When the user successfully scans the QR code for authorization, this data will be stored in the user's custom data.{"school":"hust"}
contextobjectNo-When type is WECHAT_OFFICIAL_ACCOUNT or WECHAT_MINIPROGRAM, specify a custom pipeline context, which will be passed in the pipeline context{"source":"utm"}
autoMergeQrCodebooleanNo-When type is WECHAT_MINIPROGRAM, whether to automatically merge the custom logo into the generated image, the default value is false. The process of merging QR codes on the server will increase the interface response speed. It is recommended to use the default value and stitch the images on the client. If you use the GenAuth SDK, you can save the manual stitching process.

¶ Sample Code

package test.authentication;

import cn.authing.sdk.java.client.AuthenticationClient;
import cn.authing.sdk.java.dto.GeneQRCodeRespDto;
import cn.authing.sdk.java.dto.GenerateQrcodeDto;
import cn.authing.sdk.java.enums.AuthMethodEnum;
import cn.authing.sdk.java.model.AuthenticationClientOptions;
import cn.authing.sdk.java.util.JsonUtils;

public class GeneQrCodeTest {
    // Need to be replaced with your GenAuth App ID
    private static final String APP_ID = "AUTHING_APP_ID";
    // Need to be replaced with your GenAuth App Secret
    private static final String APP_SECRET = "AUTHING_APP_SECRET";
    // Need to be replaced with your GenAuth App Host
    private static final String APP_HOST = "AUTHING_APP_HOST";

    public static void main(String[] args) throws Throwable {
        AuthenticationClientOptions clientOptions = new AuthenticationClientOptions();
        clientOptions.setAppId(APP_ID);
        clientOptions.setAppSecret(APP_SECRET);
        clientOptions.setAppHost(APP_HOST);

        AuthenticationClient client = new AuthenticationClient(clientOptions);

        GenerateQrcodeDto reqDto = new GenerateQrcodeDto();
        reqDto.setType(GenerateQrcodeDto.Type.MOBILE_APP);
        GeneQRCodeRespDto response = client.geneQrCode(reqDto);
        System.out.println(JsonUtils.serialize(response));
    }
}

¶ Request Response

Type: GeneQRCodeRespDto

NameTypeDescription
statusCodenumberBusiness status code, which can be used to determine whether the operation is successful. 200 means success.
messagestringDescription
apiCodenumberSegmented error code, which can be used to get the specific error type (successful request does not return). For a detailed list of error codes, please see: API Code List (opens new window)
requestIdstringRequest ID. Returned when the request fails.
dataGeneQRCodeDataDtoResponse data

Example Results:

{
  "statusCode": 200,
  "message": "Operation successful",
  "requestId": "934108e5-9fbf-4d24-8da1-c330328abd6c",
  "data": {
    "qrcodeId": "gQE-8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyMGJjX",
    "url": "https://files.authing.co/user-contentsqrcode/59f86b4832eb28071bdd9214/gQE-8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyMGJjX1ZhOFNiM1UxV29GVTF5MWMAAgQY4_RiAwSAxhMA.png",
    "customLogoUrl": "https://files.authing.co/authing-console/social-connections/wechatMiniLogin.svg"
  }
}

¶ Data Structure

¶ GeneQRCodeDataDto

NameType
Required
Description
Sample value
qrcodeIdstringYesThe unique ID of the QR code. The QR code status can be queried through this unique ID.gQE-8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyMGJjX
urlstringYesThe QR code URL. The front end can render the QR code based on this link.https://files.authing.co/user-contentsqrcode/59f86b4832eb28071bdd9214/gQE-8TwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyMGJjX1ZhOFNiM1UxV29GVTF5MWMAAgQY4_RiAwSAxhMA.png
customLogoUrlstringNoIf the mini program scan code login is used and Request Parameters autoMergeQrCode is set to false, the configured custom logo will be returned, and the front end can stitch this logo onto the QR code URL by itself.https://files.authing.co/authing-console/social-connections/wechatMiniLogin.svg
Previous article: Get Alipay AuthInfo Next article: Query QR code status
  • Method Name
  • Request Parameters
  • Sample Code
  • Request Response
  • Data Structure

User identity management

Integrated third-party login
Customized authentication process

Enterprise internal management

Single sign-on
Multi-factor authentication
Permission management

Developer

Development Documentation
GitHub (opens new window)

Company

official@genauth.ai
16th Floor, Building B, Beichen Century Center, Chaoyang District, Beijing (Total)
Room 406, 4th Floor, Block B, No. 200, Tianfu Fifth Street, High-tech Zone, Chengdu (Branch)

© Beijing Steamory Technology Co., Ltd.