auth
User Login Authentication
The auth method establishes the secure context between the SDK and the business user. Before any game download or launch operation, you must sync the userSignature generated by your business server to the SDK through this interface.
Register an authentication invalidation listener before the first authentication to receive a callback if the current account’s authentication later becomes invalid.
Method Declaration
java
/**
* User login authentication
*
* @param userSignature User authentication signature
* @param listener Authentication result listener
*/
public static void auth(String userSignature, SUDOPAuthListener listener);Parameters
Encapsulates the token information required for authentication:
| Field | Type | Description |
|---|---|---|
| userSignature | String | Required. The encrypted signature generated by your business server, used to verify the user's identity. |
SUDOPAuthListener
Receives authentication status callbacks:
void onSuccess(): Authentication succeeded. The SDK has established a valid user session.void onFailure(int retCode, String retMsg): Authentication failed. Possible causes include an expired signature, malformed signature, or network error.
Example Code
java
// Initiate the authentication request
SUDOP.auth("YOUR_SERVER_GENERATED_SIGNATURE", new SUDOPAuthListener() {
@Override
public void onSuccess() {
// Authentication succeeded; you can now call startGameByGameId to start the game
Log.i("SUDOP", "User authenticated successfully.");
}
@Override
public void onFailure(int retCode, String retMsg) {
// Authentication failed; check that userSignature was generated correctly
Log.e("SUDOP", "Auth failed: " + retMsg + " (Code: " + retCode + ")");
}
});Notes
- Validity:
userSignaturetypically has an expiration time. Make sure to call this interface before the signature expires. - Call order: Must be called after the
initSDKsuccess callback. - State override: Calling
authmultiple times updates the SDK's current user context. If the App switches accounts, call this interface again to update the user information.
