OpenPass SDK for Unity reference
This comprehensive reference guide documents the classes used to integrate OpenPass single sign-on (SSO) with Unity on Android and iOS devices.
For background information on the OpenPass service, and general information on implementation, see Getting started with OpenPass.
OpenPassManager
public class OpenPassManager
Manages the integration of the OpenPass SDK for platform-specific functionality (Android/iOS). Provides methods for initializing the SDK, launching the sign-in flow, and signing out.
The following table describes different attributes of the OpenPassManager class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < OpenPassManager |
| Inherited members | The following members are inherited:
|
Constructors
OpenPassManager(string, string, bool, Environment?)
Initializes the Openpass manager. This constructor prepares the manager to handle SDK interactions. If the environment parameter is null, the production environment will be used by default.
The following table lists the constructors for the OpenPassManager class.
| Method | Parameters | Exceptions |
|---|---|---|
public OpenPassManager(string clientId, string redirectHost, bool isLoggingEnabled = false, Environment? environment = null) |
|
|
Properties
The following table lists the properties for the OpenPassManager class.
| Property | Description | Declaration | Value |
|---|---|---|---|
CurrentTokens |
Read-only property to get the current OpenPass tokens. | public OpenPassTokens? CurrentTokens { get; } |
OpenPassTokens |
Methods
The following table lists the methods for the OpenPassManager class.
| Method | Description | Declaration |
|---|---|---|
SignOut() |
Signs the user out of the OpenPass SDK. Calls platform-specific implementations to handle the sign-out process. | public void SignOut() |
Events
The following table lists the events for the OpenPassManager class.
| Event | Description | Declaration | Type |
|---|---|---|---|
ExceptionEvent |
Event published when user (token) restoration fails on initialization. | public event EventHandler<ExceptionEventArgs>? ExceptionEvent |
EventHandler <ExceptionEventArgs> |
UserChanged |
Event published when the user (token) state changes, such as sign-in, sign-out, or when tokens are refreshed. | public event EventHandler<UserChangedEventArgs>? UserChanged |
EventHandler <UserChangedEventArgs> |
OpenPassTokens
The following table describes different attributes of the OpenPassTokens class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Definition | public sealed record OpenPassTokens : IEquatable<OpenPassTokens> |
| Inheritance structure | object < OpenPassTokens |
| Interface implemented | IEquatable <OpenPassTokens> |
| Inherited members | The following members are inherited:
|
Constructors
The following table lists the constructors for the OpenPassTokens class.
| Constructor | Method | Parameters |
|---|---|---|
OpenPassTokens(string, string, string, string, long, long, long, long) |
public OpenPassTokens(string idTokenJWT, string accessToken, string refreshToken, string tokenType, long expiresIn, long idTokenExpiresIn, long refreshTokenExpiresIn, long issuedAt) |
|
Properties
The following table lists the properties for the OpenPassTokens class.
| Property | Description | Declaration | Value |
|---|---|---|---|
AccessToken |
Access Token. | public string AccessToken { get; } |
String |
ExpiresIn |
The lifetime in seconds of the access token. | public long ExpiresIn { get; } |
Long |
IdTokenExpiresIn |
The lifetime in seconds of the ID token. | public long IdTokenExpiresIn { get; } |
Long |
IdTokenJWT |
ID token as JWT. | public string IdTokenJWT { get; } |
String |
IssuedAt |
The time (in epoch seconds) when the tokens were created. | public long IssuedAt { get; } |
Long |
RefreshToken |
Refresh token. | public string RefreshToken { get; } |
String |
RefreshTokenExpiresIn |
The lifetime in seconds of the refresh token. | public long RefreshTokenExpiresIn { get; } |
Long |
TokenType |
Type of access token. | public string TokenType { get; } |
String |
UserChangedEventArgs
public class UserChangedEventArgs : EventArgs
The following table describes different attributes of the UserChangedEventArgs class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < EventArgs < UserChangedEventArgs |
| Inherited members | The following members are inherited:
|
Fields
The following table describes fields used by the UserChangedEventArgs class.
| Field | Declaration | Value |
|---|---|---|
tokens |
public readonly OpenPassTokens? Tokens |
OpenPassTokens |
ExceptionEventArgs
public class ExceptionEventArgs : EventArgs
The following table describes different attributes of the ExceptionEventArgs class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < EventArgs < ExceptionEventArgs |
| Inherited members | The following members are inherited:
|
Fields
The following table describes fields used by the ExceptionEventArgs class.
| Field | Declaration | Value |
|---|---|---|
Exception |
public readonly OpenPassException Exception |
OpenPassException |
WebSignInFlowClient
public class WebSignInFlowClient
Manages the web-based sign-in flow for the OpenPass SDK. This class interacts with the Openpass manager to handle the sign-in process.
The following table describes different attributes of the WebSignInFlowClient class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < WebSignInFlowClient |
| Inherited Members | The following members are inherited:
|
WebSignInFlowClient
The following table lists the constructors for the WebSignInFlowClient class.
| Constructor | Description | Method | Parameters |
|---|---|---|---|
WebSignInFlowClient(string, OpenPassManager) |
Initializes a new instance of the WebSignInFlowClient class. |
public WebSignInFlowClient(string clientId, OpenPassManager manager) |
|
Methods
The following table lists the methods for the WebSignInFlowClient class.
| Method | Description | Declaration | Returns | Exceptions |
|---|---|---|---|---|
LaunchSignIn() |
Launches the web-based sign-in flow by delegating to the platform-specific implementation. This method triggers the appropriate sign-in process for the current platform. | public Task LaunchSignIn() |
Task |
|
RefreshTokenFlowClient
public class RefreshTokenFlowClient
Manages the refresh token flow for the OpenPass SDK. This class interacts with the Openpass manager to process the updated tokens.
The following table describes different attributes of the RefreshTokenFlowClient class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < RefreshTokenFlowClient |
| Inherited members | The following members are inherited:
|
Constructors
RefreshTokenFlowClient(string, OpenPassManager)
Initializes a new instance of the refresh token flow client with the provided client ID and Openpass manager.
The following table lists the constructors for the RefreshTokenFlowClient class.
| Method | Parameters |
|---|---|
public RefreshTokenFlowClient(string clientId, OpenPassManager manager) |
|
Methods
The following table lists the methods for the RefreshTokenFlowClient class.
| Method | Description | Declaration | Parameters | Returns | Exceptions |
|---|---|---|---|---|---|
Refresh(string) |
Refreshes OpenPass tokens using the provided refresh token. | public Task<OpenPassTokens> Refresh(string refreshToken) |
refreshToken (string): The refresh token to be used to obtain a new tokens. |
Task <OpenPassTokens> |
OpenPassException: Thrown when the flow is not successful. |
Environment
public abstract record Environment : IEquatable<Environment>
The following table describes different attributes of the Environment class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < Environment |
| Interface implemented | IEquatable <Environment> |
| Derived classes | CustomEnvironment, ProductionEnvironment, StagingEnvironment |
| Inherited members | The following members are inherited:
|
ProductionEnvironment
public sealed record ProductionEnvironment : Environment, IEquatable<Environment>, IEquatable<ProductionEnvironment>
Represents the default environment used in production.
The following table describes different attributes of the ProductionEnvironment class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < Environment < ProductionEnvironment |
| Interface implemented | IEquatable <Environment>, IEquatable <ProductionEnvironment> |
| Inherited members | The following members are inherited:
|
StagingEnvironment
public sealed record StagingEnvironment : Environment, IEquatable<Environment>, IEquatable<StagingEnvironment>
Represents the staging environment for internal development.
The following table describes different attributes of the StagingEnvironment class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < Environment < StagingEnvironment |
| Interface implemented | IEquatable <Environment>, IEquatable <StagingEnvironment> |
| Inherited members | The following members are inherited:
|
CustomEnvironment
public sealed record CustomEnvironment : Environment, IEquatable<Environment>, IEquatable<CustomEnvironment>
Represents a custom environment with a user-defined API server URL.
The following table describes different attributes of the CustomEnvironment class.
| Attribute | Details | |
|---|---|---|
| Namespace | OpenPass | |
| Assembly | OpenPassRuntime.dll |
|
| Inheritance structure | object < Environment < CustomEnvironment |
|
| Interface implemented | IEquatable <Environment>, IEquatable <CustomEnvironment> |
|
| Inherited members | The following members are inherited:
|
The |
Constructors
The following table lists the constructors for the CustomEnvironment class.
| Constructor | Description | Method | Parameters |
|---|---|---|---|
CustomEnvironment(Uri) |
Initializes a new instance of the custom environment using the API server URL as a parameter. | public CustomEnvironment(Uri ServerUrl) |
ServerUrl (URI) |
OpenPassException
public class OpenPassException : Exception, ISerializable
Base class for all custom exceptions reported by the OpenPass SDK.
The following table describes different attributes of the OpenPassException class.
| Attribute | Details | |
|---|---|---|
| Namespace | OpenPass | |
| Assembly | OpenPassRuntime.dll |
|
| Inheritance structure | object < Exception < OpenPassException |
|
| Interface implemented | ISerializable |
|
| Derived classes | BrowserUnavailableException, InitializationException |
|
| Inherited members | The following members are inherited:
|
- |
Constructors
The following table lists the constructors for the OpenPassException class.
| Constructor | Method | Parameters |
|---|---|---|
OpenPassException() |
public OpenPassException() |
N/A |
OpenPassException(string?) |
public OpenPassException(string? message) |
message (string) |
OpenPassException(string?, Exception?) |
public OpenPassException(string? message = null, Exception? cause = null) |
message (string), cause (exception) |
BrowserUnavailableException
public class BrowserUnavailableException : OpenPassException, ISerializable
The exception is thrown when there is no browser available.
The following table describes different attributes of the BrowserUnavailableException class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < Exception < OpenPassException < BrowserUnavailableException |
| Interface implemented | ISerializable. Allows the exception to be serialized, which is useful for remoting or for saving the state of the exception. |
| Inherited members | The following members are inherited:
|
Constructors
The following table lists the constructors for the BrowserUnavailableException class.
| Constructor | Method | Parameters |
|---|---|---|
BrowserUnavailableException() |
public BrowserUnavailableException() |
N/A |
BrowserUnavailableException(string?) |
public BrowserUnavailableException(string? message) |
message (string) |
BrowserUnavailableException(string?, Exception?) |
public BrowserUnavailableException(string? message = null, Exception? cause = null) |
message (string), cause (exception) |
InitializationException
public class InitializationException : OpenPassException, ISerializable
The SDK failed to initialize.
The following table describes different attributes of the InitializationException class.
| Attribute | Details |
|---|---|
| Namespace | OpenPass |
| Assembly | OpenPassRuntime.dll |
| Inheritance structure | object < Exception < OpenPassException < InitializationException |
| Interface implemented | ISerializable |
| Inherited members | The following members are inherited:
|
Constructors
The following table lists the constructors for the InitializationException class.
| Constructor | Method | Parameters |
|---|---|---|
InitializationException() |
public InitializationException() |
N/A |
InitializationException(string?) |
public InitializationException(string? message) |
message (string) |
InitializationException(string?, Exception?) |
public InitializationException(string? message = null, Exception? cause = null) |
message (string), cause (exception) |