# auth.code2Session

Call this API at the server side. For more information, see Server API.

Verifies the login credential. The temporary login credential code is obtained via the wx.login API and passed into WeChat DevTools, which calls this API to complete the login procedure. For more usages, see Mini Program Login.

# Request Address

GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code

# Request Parameters

Attribute Type Default Required Description
appid string Yes The appId of the Mini Program.
secret string Yes The appSecret of the Mini Program
js_code string Yes The code obtained during login
grant_type string Yes The authorization type. Enter authorization_code.

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
openid string The unique identifier of the user
session_key string The session key
unionid string The unique identifier of the user on the open platform. It is returned when the sending conditions for the UnionID are met. For details, see UnionID Mechanism.
errcode number Error code
errmsg string Error message

Valid values of errcode

Value Description Minimum Version
-1 System is busy. Try again later.
0 Request successful
40029 Invalid code
45011 Frequency limit exceeded. The limit is 100 times per minute for each user.