All Products
Search
Document Center

SuperApp:wv.getAuthCode

Last Updated:Jun 03, 2026

Requests user authorization and returns an authorization code (authCode).

Overview

wv.getAuthCode displays an authorization pop-up requesting the user's permission to access their information. Call this method only after the user understands why authorization is needed. Do not call it on the miniapp's initial screen.

The returned authCode represents user consent. Your server uses this code to retrieve user information from the platform, such as user_id, avatar, nickname, mobile number, region, gender, and date of birth.

Request parameters

Pass an object with these parameters:

Parameter

Type

Required

Description

scopes

Array

No

Authorization scopes. Valid values are listed in the Scopes table below. Defaults to ['auth_base'].

success

Function

No

Callback on success.

fail

Function

No

Callback on failure.

Scopes

Each scope defines a permission your miniapp requests from the user.

Scope

Description

Server action

USER_ID

Deprecated. This scope is an alias for auth_base.

See auth_base.

USER_NICKNAME

Grants access to the user's nickname.

Pass the authCode to your server to retrieve the authorized user information.

USER_NAME

Grants access to the user's name.

Pass the authCode to your server to retrieve the authorized user information.

USER_LOGIN_ID

Grants access to the user's login ID.

Pass the authCode to your server to retrieve the authorized user information.

HASH_LOGIN_ID

Grants access to the hashed login ID.

Pass the authCode to your server to retrieve the authorized user information.

USER_AVATAR

Grants access to the user's avatar.

Pass the authCode to your server to retrieve the authorized user information.

USER_GENDER

Grants access to the user's gender.

Pass the authCode to your server to retrieve the authorized user information.

USER_BIRTHDAY

Grants access to the user's date of birth.

Pass the authCode to your server to retrieve the authorized user information.

USER_NATIONALITY

Grants access to the user's nationality.

Pass the authCode to your server to retrieve the authorized user information.

USER_CONTACTINFO

Grants access to the user's contact information.

Pass the authCode to your server to retrieve the authorized user information.

auth_base

Grants access to the user's unique identifier (user_id). This is a silent authorization that does not display an authorization pop-up.

Pass the authCode to your server to retrieve the user's unique identifier (user_id).

auth_user

Grants access to the user's account information.

Pass the authCode to your server to retrieve the authorized user information.

Response parameters

The success callback receives an object with these properties:

Property

Type

Description

authCode

String

The authorization code.

authErrorScopes

Object

Maps failed scopes to their error codes.

authSuccessScopes

Array

Successfully authorized scopes.

Note

A new authCode is generated each time the user grants authorization.

The fail callback receives an object with error (error code) and errorMessage (error message) properties.

Error code

Error message

Solution

11

User canceled authorization

Explain why authorization is needed and prompt the user to retry.

12

Network error

The authorization request failed or timed out. Try again later.

13

No authorization result found

Invalid value in scopes. Ensure you pass an array of valid scopes.

Sample code

window.WindVane.call('wv', 'getAuthCode', {scopes: ['auth_user']}, function(res) {
		authCode = res.authCode;
}, function(e) {
    alert('failure:' + JSON.stringify(e));
});