Session Management
Minigames can obtain the open platform's user identifiers through the login capability provided by OpenPaaS and quickly establish a user system within the minigame.
Description
- Call the sud.login API provided by OpenPaaS to obtain the temporary login credential
code, then submitcodeto your developer server. - The developer server uses
codeto call auth.code2session to obtain the user session data, then generates its own session based on the user identifier. That session is used to identify the user in subsequent client-server interactions.
User identifiers returned by auth.code2session:
| Parameter | Type | Description |
|---|---|---|
| openid | string | Unique identifier of the user within the current minigame, used to identify the user inside the minigame |
| unionid | string | Unique identifier of the user under the open platform account |
| session_key | string | Session key, used to encrypt and verify sensitive user data |
Note:
- The session key
session_keyis the key used to encrypt and sign user data. For the security of your own application, the developer server must not deliver the session key to the minigame, nor provide this key to any external party. - The temporary login credential
codecan be used only once. auth.code2sessionmust be called from the server. The request carriesgame_idandsecret, which must never appear in client code.
