Authentication with the PIXO Platform is as simple as calling the Login function. If you read the xAPI documentation, you can get a better understanding of what is happening under the hood, but the SDK automates nearly everything and makes authentication a breeze.
To authenticate, you can either pass a username and password as individual parameters, or bundle them in a LoginData object and pass that instead:
-
Login(username : string, password : string) : Boolean
-
Login(login : LoginData) : Boolean
You can also bundle a One-Time Code (generated on the PIXO Platform), as the username and call ApexSystem::Login() with an empty password string.
Features of this function are that it:
- Sends the user's information to the PIXO Platform Server to login
- Returns FALSE if the password or login are of zero length
Authentication Responses
-
OnLoginSuccess is called when the user's information is valid and has access to the module.
-
OnLoginFailed is called when the user's information is not valid, does not have access to the module, or when the server is not able to be reached.
See the Example Code section for C# examples on how to bind to the event delegates.
Authenticated Launches
When a user launches your application from the PIXO Hub App, an authentication token is passed. This token must be checked against the PIXO Platform in place of a traditional Login. There are two steps you must do to accomplish this.
First, you must get the authentication token. The property to get this is ApexSystem::PassedLoginToken. It returns an empty string or null value when there is no token available, but returns a valid string when a token is available.
If you receive a valid string from the first step, ApexSystem::LoginWithToken() allows you to login with this token.
ApexSystem::LoginWithToken() takes 1 required parameter and returns a bool.
- token:string – The authentication token that represents a currently logged in user.
- Returns TRUE on success.
Example Code
Calling Login Using Strings
ApexSystem.login("[email protected]", "123abc")
Calling Login Using LoginData
LoginData PixoLoginData = new LoginData(username:"[email protected]", password:"123abc");
ApexSystem.login(PixoLoginData)
LoginData
If you want to store authentication information in a single LoginData object, simply create a new object and pass the username and password.
public LoginData(string username, string password)
{
Login = username;
Password = password;
}
Next Article: Data Reporting > Sessions
Previous Article: PIXO Platform Integration Requirements