Photon .NET Client API 4.1.4.8

Public Member Functions | Properties | List of all members
Photon.Chat.AuthenticationValues Class Reference

Container for user authentication in Photon. Set AuthValues before you connect - all else is handled. More...

Public Member Functions

 AuthenticationValues ()
 Creates empty auth values without any info. More...
 
 AuthenticationValues (string userId)
 Creates minimal info about the user. If this is authenticated or not, depends on the set AuthType. More...
 
virtual void SetAuthPostData (string stringData)
 Sets the data to be passed-on to the auth service via POST. More...
 
virtual void SetAuthPostData (byte[] byteData)
 Sets the data to be passed-on to the auth service via POST. More...
 
virtual void SetAuthPostData (Dictionary< string, object > dictData)
 Sets data to be passed-on to the auth service as Json (Content-Type: "application/json") via Post. More...
 
virtual void AddAuthParameter (string key, string value)
 Adds a key-value pair to the get-parameters used for Custom Auth (AuthGetParameters). More...
 
override string ToString ()
 Transform this object into string. More...
 
AuthenticationValues CopyTo (AuthenticationValues copy)
 Make a copy of the current object. More...
 

Properties

CustomAuthenticationType AuthType [get, set]
 The type of authentication provider that should be used. Defaults to None (no auth whatsoever). More...
 
string AuthGetParameters [get, set]
 This string must contain any (http get) parameters expected by the used authentication service. By default, username and token. More...
 
object AuthPostData [get]
 Data to be passed-on to the auth service via POST. Default: null (not sent). Either string or byte[] (see setters). More...
 
string Token [get, set]
 Internal Photon token. After initial authentication, Photon provides a token for this client, subsequently used as (cached) validation. More...
 
string UserId [get, set]
 The UserId should be a unique identifier per user. This is for finding friends, etc.. More...
 

Detailed Description

Container for user authentication in Photon. Set AuthValues before you connect - all else is handled.

On Photon, user authentication is optional but can be useful in many cases. If you want to FindFriends, a unique ID per user is very practical.

There are basically three options for user authentication: None at all, the client sets some UserId or you can use some account web-service to authenticate a user (and set the UserId server-side).

Custom Authentication lets you verify end-users by some kind of login or token. It sends those values to Photon which will verify them before granting access or disconnecting the client.

The AuthValues are sent in OpAuthenticate when you connect, so they must be set before you connect. If the AuthValues.UserId is null or empty when it's sent to the server, then the Photon Server assigns a UserId!

The Photon Cloud Dashboard will let you enable this feature and set important server values for it. https://dashboard.photonengine.com

Constructor & Destructor Documentation

◆ AuthenticationValues() [1/2]

Photon.Chat.AuthenticationValues.AuthenticationValues ( )
inline

Creates empty auth values without any info.

◆ AuthenticationValues() [2/2]

Photon.Chat.AuthenticationValues.AuthenticationValues ( string  userId)
inline

Creates minimal info about the user. If this is authenticated or not, depends on the set AuthType.

Parameters
userIdSome UserId to set in Photon.

Member Function Documentation

◆ AddAuthParameter()

virtual void Photon.Chat.AuthenticationValues.AddAuthParameter ( string  key,
string  value 
)
inlinevirtual

Adds a key-value pair to the get-parameters used for Custom Auth (AuthGetParameters).

This method does uri-encoding for you.

Parameters
keyKey for the value to set.
valueSome value relevant for Custom Authentication.

◆ CopyTo()

AuthenticationValues Photon.Chat.AuthenticationValues.CopyTo ( AuthenticationValues  copy)
inline

Make a copy of the current object.

Parameters
copyThe object to be copied into.
Returns
The copied object.

◆ SetAuthPostData() [1/3]

virtual void Photon.Chat.AuthenticationValues.SetAuthPostData ( byte[]  byteData)
inlinevirtual

Sets the data to be passed-on to the auth service via POST.

AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.

Parameters
byteDataBinary token / auth-data to pass on.

◆ SetAuthPostData() [2/3]

virtual void Photon.Chat.AuthenticationValues.SetAuthPostData ( Dictionary< string, object >  dictData)
inlinevirtual

Sets data to be passed-on to the auth service as Json (Content-Type: "application/json") via Post.

AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.

Parameters
dictDataA authentication-data dictionary will be converted to Json and passed to the Auth webservice via HTTP Post.

◆ SetAuthPostData() [3/3]

virtual void Photon.Chat.AuthenticationValues.SetAuthPostData ( string  stringData)
inlinevirtual

Sets the data to be passed-on to the auth service via POST.

AuthPostData is just one value. Each SetAuthPostData replaces any previous value. It can be either a string, a byte[] or a dictionary.

Parameters
stringDataString data to be used in the body of the POST request. Null or empty string will set AuthPostData to null.

◆ ToString()

override string Photon.Chat.AuthenticationValues.ToString ( )
inline

Transform this object into string.

Returns
string representation of this object.

Property Documentation

◆ AuthGetParameters

string Photon.Chat.AuthenticationValues.AuthGetParameters
getset

This string must contain any (http get) parameters expected by the used authentication service. By default, username and token.

Maps to operation parameter 216. Standard http get parameters are used here and passed on to the service that's defined in the server (Photon Cloud Dashboard).

◆ AuthPostData

object Photon.Chat.AuthenticationValues.AuthPostData
get

Data to be passed-on to the auth service via POST. Default: null (not sent). Either string or byte[] (see setters).

Maps to operation parameter 214.

◆ AuthType

CustomAuthenticationType Photon.Chat.AuthenticationValues.AuthType
getset

The type of authentication provider that should be used. Defaults to None (no auth whatsoever).

Several auth providers are available and CustomAuthenticationType.Custom can be used if you build your own service.

◆ Token

string Photon.Chat.AuthenticationValues.Token
getset

Internal Photon token. After initial authentication, Photon provides a token for this client, subsequently used as (cached) validation.

Any token for custom authentication should be set via SetAuthPostData or AddAuthParameter.

◆ UserId

string Photon.Chat.AuthenticationValues.UserId
getset

The UserId should be a unique identifier per user. This is for finding friends, etc..

See remarks of AuthValues for info about how this is set and used.


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