Astra Unity 2.6.6
Astra Unity Plugin
Astra.Auth Class Reference

Contains functionality to login customers with the Astra service, and other related operations More...

Classes

struct  Cookie
 Used to represent cookie data from the TyGetCookieData call More...
 

Public Types

enum  AuthError {
  Success = 0 , InvalidEmailOrPassword , EmailInUse , EmailNotRegistered ,
  UnknownError
}
 States of authentication errors for registration and logging in More...
 

Static Public Member Functions

static string GetAppId ()
 Returns the current app's id, this is the same as the application id on the admin portal. More...
 
static string GetBaseUrl ()
 Returns the base URL for Astra service requests More...
 
static string GetCookie ()
 Gets the full cookie necessary for authorizing Astra service API requests. This call will only result in a valid cookie after you successfully log a user in. Note this is the full cookie it may look something like "s=xyz..." where the prefix "s=" is the cookie name and "xyz..." is the cookie value In most cases you are looking for GetSessionId and RestoreSession. More...
 
static bool TryGetCookieData (out Cookie cookie)
 Retrieves the Auth.Cookie from the session data. This gives you back the struct so you don't need to parse the cookie manually if you prefer. More...
 
static string GetSessionId ()
 Retrieves the session id without the cookie data. This means that if the cookie looks like "s=xyz..." you will get back "xyz..." This is useful when calling RestoreSession to log a user in at a future time. More...
 
static bool SetEnvironmentCustom (string uri)
 Sets the Astra Service to target the specified environment, this is not normally called directly. Instead you should provide a ProjectConfiguration JSON to Configuration.Initialize instead. Your environment will look like https://[COMPANYNAME].maketafi.com More...
 
static LoginJob LoginWithAstraId (string email, string password)
 Log into the Astra service, if you have your own IDs you likely want to use LoginRemote instead More...
 
static LoginJob Login (string email, string password)
 Log into the Astra service, if you have your own IDs you likely want to use LoginRemote instead More...
 
static RemoteLoginJob LoginRemote (string remoteType, string remoteId, string password)
 Login using a remote authentication provider More...
 
static RegisterJob Register (string email, string handle, string password)
 Registers a new account using Tafi's account system, if you have your own IDs you likely want to use the RegisterRemote instead More...
 
static RegisterRemoteJob RegisterRemote (string remoteType, string remoteId, string handle, string password)
 Registers a new account using a remote type, please ask the Astra Service for your appropriate remoteType string This is used for 3rd part systems where you don't want to create a astra id directly More...
 
static LoginRegisterRemoteJob LoginRegisterRemote (string remoteType, string remoteId, string handle, string password)
 Combines logging and and registering in one job, see RegisterRemote and LoginRemote for instructions More...
 
static ForgotPasswordJob ForgotPasswordForAstraId (string email)
 Institures a request to reset the user's password More...
 
static SetAppJob SetApp (ulong appId, string secretKey)
 Set Application information, for use in cookies More...
 
static PingJob PingAstra ()
 Pings the Tafi servers to check for network connectivitiy and server status. Check the job's success state to determine if it was able to communicate properly. More...
 
static LogoutJob Logout ()
 Logout the active user More...
 
static RestoreSessionJob RestoreSession (string sessionId)
 This is useful if you wish to maintin the user's session state with the Tafi server between application launches. Internally the Astra library does not permanently store the user's session/cookie data calling this function allows you to provide the cookie string and "relogin" the user. You can get the session id string from GetSessionId. More...
 
static WhoAmIJob WhoAmI ()
 Get User Information such as the the user id and handle via Astra.WhoAmIResult. More...
 

Detailed Description

Contains functionality to login customers with the Astra service, and other related operations

Member Enumeration Documentation

◆ AuthError

States of authentication errors for registration and logging in

Enumerator
Success 

The request succeeded.

InvalidEmailOrPassword 

The request failed do to a bad email, rmeote id, or password.

EmailInUse 

The request failed do to a the email or remote id already being used.

EmailNotRegistered 

The request failed do to a the email or remote id not being found.

UnknownError 

The request failed do to an unknown error, check the native Astra logs.

Member Function Documentation

◆ ForgotPasswordForAstraId()

static ForgotPasswordJob Astra.Auth.ForgotPasswordForAstraId ( string  email)
inlinestatic

Institures a request to reset the user's password

Parameters
emailEmail attached to the user's account

◆ GetAppId()

static string Astra.Auth.GetAppId ( )
inlinestatic

Returns the current app's id, this is the same as the application id on the admin portal.

Returns
A string containing your application id or a null on failure

◆ GetBaseUrl()

static string Astra.Auth.GetBaseUrl ( )
inlinestatic

Returns the base URL for Astra service requests

Returns
A complete uri such as "https://example.maketafi.com"

◆ GetCookie()

static string Astra.Auth.GetCookie ( )
inlinestatic

Gets the full cookie necessary for authorizing Astra service API requests. This call will only result in a valid cookie after you successfully log a user in. Note this is the full cookie it may look something like "s=xyz..." where the prefix "s=" is the cookie name and "xyz..." is the cookie value In most cases you are looking for GetSessionId and RestoreSession.

Returns
A session cookie id

◆ GetSessionId()

static string Astra.Auth.GetSessionId ( )
inlinestatic

Retrieves the session id without the cookie data. This means that if the cookie looks like "s=xyz..." you will get back "xyz..." This is useful when calling RestoreSession to log a user in at a future time.

Returns
The session id on success, otherwise a null

◆ Login()

static LoginJob Astra.Auth.Login ( string  email,
string  password 
)
inlinestatic

Log into the Astra service, if you have your own IDs you likely want to use LoginRemote instead

Parameters
emailEmail used for this account
passwordPassword for this account

◆ LoginRegisterRemote()

static LoginRegisterRemoteJob Astra.Auth.LoginRegisterRemote ( string  remoteType,
string  remoteId,
string  handle,
string  password 
)
inlinestatic

Combines logging and and registering in one job, see RegisterRemote and LoginRemote for instructions

Parameters
remoteTypeType for the remote authentication as provided by Astra Service
remoteIdID for the remote user account specific to this app
handleUser handle for this account
paswordPassword for this account (currently must be 6 characters or longer)

◆ LoginRemote()

static RemoteLoginJob Astra.Auth.LoginRemote ( string  remoteType,
string  remoteId,
string  password 
)
inlinestatic

Login using a remote authentication provider

Parameters
remoteTypeType for the remote authentication as provided by Astra Service
remoteIdID for the remote user account specific to this app
passwordPassword for this account

◆ LoginWithAstraId()

static LoginJob Astra.Auth.LoginWithAstraId ( string  email,
string  password 
)
inlinestatic

Log into the Astra service, if you have your own IDs you likely want to use LoginRemote instead

Parameters
emailEmail used for this account
passwordPassword for this account

◆ Logout()

static LogoutJob Astra.Auth.Logout ( )
inlinestatic

Logout the active user

Returns
A job you can wait upon for completion and status

◆ PingAstra()

static PingJob Astra.Auth.PingAstra ( )
inlinestatic

Pings the Tafi servers to check for network connectivitiy and server status. Check the job's success state to determine if it was able to communicate properly.

Returns
A job which you can check it's success state to determine if the server is online.

◆ Register()

static RegisterJob Astra.Auth.Register ( string  email,
string  handle,
string  password 
)
inlinestatic

Registers a new account using Tafi's account system, if you have your own IDs you likely want to use the RegisterRemote instead

Parameters
emailA unique email for the user you want to register
handleUser handle for this account
paswordPassword for this account (currently must be 6 characters or longer)

◆ RegisterRemote()

static RegisterRemoteJob Astra.Auth.RegisterRemote ( string  remoteType,
string  remoteId,
string  handle,
string  password 
)
inlinestatic

Registers a new account using a remote type, please ask the Astra Service for your appropriate remoteType string This is used for 3rd part systems where you don't want to create a astra id directly

Parameters
remoteTypeType for the remote authentication as provided by Astra Service
remoteIdID for the remote user account specific to this app
handleUser handle for this account
paswordPassword for this account (currently must be 6 characters or longer)

◆ RestoreSession()

static RestoreSessionJob Astra.Auth.RestoreSession ( string  sessionId)
inlinestatic

This is useful if you wish to maintin the user's session state with the Tafi server between application launches. Internally the Astra library does not permanently store the user's session/cookie data calling this function allows you to provide the cookie string and "relogin" the user. You can get the session id string from GetSessionId.

Parameters
sessionIdThe id for the session to restore
Returns
A job that you can wait upon completion to ensure the user is properly logged in

◆ SetApp()

static SetAppJob Astra.Auth.SetApp ( ulong  appId,
string  secretKey 
)
inlinestatic

Set Application information, for use in cookies

Parameters
appIdApplication ID
secretKeySecret Key for the application

◆ SetEnvironmentCustom()

static bool Astra.Auth.SetEnvironmentCustom ( string  uri)
inlinestatic

Sets the Astra Service to target the specified environment, this is not normally called directly. Instead you should provide a ProjectConfiguration JSON to Configuration.Initialize instead. Your environment will look like https://[COMPANYNAME].maketafi.com

Parameters
uriYour custome URI such as "https://example.maketafi.com"
Returns
True if successfully swapped, false otherwise

◆ TryGetCookieData()

static bool Astra.Auth.TryGetCookieData ( out Cookie  cookie)
inlinestatic

Retrieves the Auth.Cookie from the session data. This gives you back the struct so you don't need to parse the cookie manually if you prefer.

Parameters
cookieThe cookie the data will be inserted into
Returns
True if the cookie was loaded, false otherwise

◆ WhoAmI()

static WhoAmIJob Astra.Auth.WhoAmI ( )
inlinestatic

Get User Information such as the the user id and handle via Astra.WhoAmIResult.

Returns
A job you can wait upon and get the user information, Astra.WhoAmIJob.

The documentation for this class was generated from the following file: