Authentication Plugin Functions
Authentication is a top-level service based on Users and Devices tables that provide the ability to authenticate and authorize users and generate tokens for them. In the following, we will review the functions of authentication service in plugins:
Login with email
This function will login a player with pair of email and password, and return the token as result.
- Unity3D
- TypeScript
DynamicPixels.Authentication.LoginWithEmail(LoginWithEmailParams input);
DynamicPixels.Auth.LoginWithEmail(input: LoginWithEmailParams): Promise<LoginResponse>;
Register with email
This function will register a new user and then login him in and return the token.
- Unity3D
- TypeScript
DynamicPixels.Authentication.RegisterWithEmail(RegisterWithEmailParams input);
DynamicPixels.Auth.RegisterWithEmail(input: RegisterWithEmailParams): Promise<LoginResponse>;
Login with Google
With this function, you can login user with Google Auth.
- Unity3D
- TypeScript
DynamicPixels.Authentication.LoginWithGoogle(LoginWithGoogleParams input);
DynamicPixels.Auth.LoginWithGoogle(input: LoginWithGoogleParams): Promise<LoginResponse>;
Login as guest
If you want to login users easily and don't show any form, guest login is for you! This function will login users with a unique id and mark the user as a guest. also, you can edit the user and add additional information in the future.
- Unity3D
- TypeScript
DynamicPixels.Authentication.LoginAsGuest(LoginAsGuestParams input);
DynamicPixels.Auth.LoginAsGuest(input: LoginAsGuestParams): Promise<LoginResponse>;
Login with token
When you login with any function, a token will return that will be used in requests to the server to identify the user. you should save this token in a safe place and load it on every game startup. to prevent login in every game session, you should call this function and pass the saved token.
- Unity3D
- TypeScript
DynamicPixels.Authentication.LoginWithToken(LoginWithTokenParams input);
DynamicPixels.Auth.LoginWithToken(input: LoginWithTokenParams): Promise<LoginResponse>;
Check OTA is ready
Check if OTA is available and developer can use it. you can fall back to other login ways if it's not available.
- Unity3D
- TypeScript
DynamicPixels.Authentication.IsOtaReady(new IsOtaReadyParams());
DynamicPixels.Auth.IsOtaReady(input: IsOtaReadyParams): Promise<boolean>;
Send OTA token
If OTA is ready, this function will generate a random key and send it as SMS to specified phone number. this key is valid for few minutes to verify.
- Unity3D
- TypeScript
DynamicPixels.Authentication.SendOtaToken(SendOtaTokenParams input);
DynamicPixels.Auth.SendOtaToken(input: SendOtaTokenParams): Promise<boolean>;
Verify OTA token
After sending OTA key, you should get it by a form and verify it with this function. after that, login process will be done.
- Unity3D
- TypeScript
DynamicPixels.Authentication.VerifyOtaToken(VerifyOtaTokenParams input);
DynamicPixels.Auth.VerifyOtaToken(input: VerifyOtaTokenParams): Promise<LoginResponse>;
Is logged in
This function return status of user athenticating.
- Unity3D
- TypeScript
DynamicPixels.Authentication.IsLoggenIn();
DynamicPixels.Auth.IsLoggedIn():boolean
Logout
This function closes all connections and forgets the user's token. then you can login another user.
- Unity3D
- TypeScript
DynamicPixels.Authentication.Logout();
DynamicPixels.Auth.Logout():void