Class Credentials
A class, representing the credentials used for authenticating a User.
Namespace: Realms.Sync
Assembly: Realm.dll
Syntax
public class Credentials
Properties
| Improve this Doc View SourceIdentityProvider
Gets the identity provider for the credentials.
Declaration
public string IdentityProvider { get; }
Property Value
Type | Description |
---|---|
String | The identity provider, such as Google, Facebook, etc. |
Token
Gets the access token.
Declaration
public string Token { get; }
Property Value
Type | Description |
---|---|
String | The access token. |
UserInfo
Gets additional user information associated with the credentials.
Declaration
public IReadOnlyDictionary<string, object> UserInfo { get; }
Property Value
Type | Description |
---|---|
IReadOnlyDictionary<String, Object> | A dictionary, containing the additional information. |
Methods
| Improve this Doc View SourceAnonymous()
Creates Credentials for an anonymous user. These can only be used once - using them a second time will result in a different user being logged in. If you need to get a user that has already logged in with the Anonymous credentials, use Current or AllLoggedIn.
Declaration
public static Credentials Anonymous()
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
AzureAD(String)
Creates Credentials based on an Active Directory login.
Declaration
public static Credentials AzureAD(string adToken)
Parameters
Type | Name | Description |
---|---|---|
String | adToken | An access token, obtained by logging into Azure Active Directory. |
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
Custom(String, String, IDictionary<String, Object>)
Creates an instance of Credentials with a custom provider and user identifier.
Declaration
public static Credentials Custom(string identityProvider, string userIdentifier, IDictionary<string, object> userInfo)
Parameters
Type | Name | Description |
---|---|---|
String | identityProvider | Provider used to verify the credentials. |
String | userIdentifier | String identifying the user. Usually a username of id. |
IDictionary<String, Object> | userInfo | Data describing the user further or null if the user does not have any extra data. The data will be serialized to JSON, so all values must be mappable to a valid JSON data type. |
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
CustomRefreshToken(String, String, Boolean)
Creates a Credentials based on a custom Refresh token.
Declaration
public static Credentials CustomRefreshToken(string token, string userId, bool isAdmin = false)
Parameters
Type | Name | Description |
---|---|---|
String | token | A Json Web Token, obtained by a 3rd party source that will be used instead of the ROS-issued refresh tokens. |
String | userId | The identity of the user. This value is used for client side validation only as the server will compute its own
value based on the |
Boolean | isAdmin | A value indicating whether the user is an admin. This value is used for client side validation only as the server
will compute its own value based on the |
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
Remarks
Unlike other Credentials methods, users logged in via the CustomRefreshToken API will not go through the regular login flow (since we already have a refresh token). Instead, the provided token will be used at any point when we need to exchange the refresh token for an access token, e.g. when opening a Realm file. If the refresh token is invalid or expired, the user instance will still be valid and they'll be able to create/open Realms, but those will never be synchronized with ROS. If the token is then updated with a new valid one, existing changes will be synchronized with the server as usual.
To update a refresh token, just set RefreshToken to the new updated value.
ROS must be configured with refreshTokenValidators
for this user to ever be able to sync with it.
Facebook(String)
Creates Credentials based on a Facebook login.
Declaration
public static Credentials Facebook(string facebookToken)
Parameters
Type | Name | Description |
---|---|---|
String | facebookToken | A Facebook authentication token, obtained by logging into Facebook. |
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
Google(String)
Creates Credentials based on a Google login.
Declaration
public static Credentials Google(string googleToken)
Parameters
Type | Name | Description |
---|---|---|
String | googleToken | A Google authentication token, obtained by logging into Google. |
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
JWT(String, String)
Creates Credentials based on a JWT access token.
Declaration
public static Credentials JWT(string token, string providerName = "jwt")
Parameters
Type | Name | Description |
---|---|---|
String | token | A Json Web Token, obtained by logging into your auth service. |
String | providerName | The name of the jwt provider in ROS. By default, it will be jwt, unless explicitly overridden by the ROS configuration. |
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
Nickname(String)
Creates Credentials based on a login with a nickname. If multiple users try to login with the same nickname, they'll get the same underlying sync user.
Declaration
[Obsolete("The Nickname auth provider is insecure and will be removed in a future version. Please use UsernamePassword or Anonymous instead.")]
public static Credentials Nickname(string value)
Parameters
Type | Name | Description |
---|---|---|
String | value | The nickname of the user. |
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |
UsernamePassword(String, String, Nullable<Boolean>)
Creates Credentials based on a login with a username and a password.
Declaration
public static Credentials UsernamePassword(string username, string password, bool? createUser = default(bool? ))
Parameters
Type | Name | Description |
---|---|---|
String | username | The username of the user. |
String | password | The user's password. |
Nullable<Boolean> | createUser |
|
Returns
Type | Description |
---|---|
Credentials | An instance of Credentials that can be used in LoginAsync(Credentials, Uri). |