RhinoAccountsManager

public static class RhinoAccountsManager
Performs various Rhino Accounts-related tasks.

Methods

ExecuteProtectedCode

#Since v7.0
public static void ExecuteProtectedCode(Action<SecretKey> protectedCode)
Any synchronous method in the IRhinoAccountsManager class must be executed within the function passed to this method, or an InvalidOperationException will be thrown.
Remarks: The code within the function passed must be kept as breif as possible for performance and security reasons.
protectedCode (Action<SecretKey>)A function returning an awaitable task that has a SecretKey passed to it. You will need to pass this secret key to any method you wish to call within IRhinoAccountsManager.
RhinoAccountsOperationInProgressExceptionAnother operation is already in progress.

ExecuteProtectedCodeAsync

#
public static Task ExecuteProtectedCodeAsync(Func<SecretKey, Task> protectedCode)
Any asynchronous method in the IRhinoAccountsManager class must be executed within the function passed to this method, or an InvalidOperationException will be thrown.
Remarks: The code within the function passed must be kept as breif as possible for performance and security reasons.
protectedCode (Func<SecretKey, Task>)A function returning an awaitable task that has a SecretKey passed to it. You will need to pass this secret key to any method you wish to call within IRhinoAccountsManager.
RhinoAccountsOperationInProgressExceptionAnother operation is already in progress.

GetAuthTokensAsync

#
public static Task<Tuple<IOpenIDConnectToken, IOAuth2Token>> GetAuthTokensAsync(string clientId, string clientSecret, IEnumerable<string> scope, string prompt, int? maxAge, bool showUI, IProgress<RhinoAccoountsProgressInfo> progress, SecretKey secretKey, CancellationToken cancellationToken)
Asynchronously retrieves auth tokens with the given criteria from the Rhino Accounts server.
clientId (string)The unique id of the client registered in Rhino Accounts.
clientSecret (string)The secret of the client registered in Rhino Accounts
scope (IEnumerable<string>)The scope desired for the tokens. Valid scope values can be found in the Rhino Accounts documentation.
prompt (string)The prompt of the request. See Rhino Accounts documentation for details. You may pass null if no prompt is desired.
maxAge (int?)The maxAge of the request. See Rhino Accounts documentation for details. You may pass null if no maxAge should be enforced.
showUI (bool)true if the user should see a UI showing the progress of the operation and a way to cancel it, or false if the UI should not be displayed. If false, it is strongly recommended that you pass a progress object and display your own UI to the user.
progress (IProgress<RhinoAccoountsProgressInfo>)An object that will report the progress of the operation to the caller. If no progress is needed, you may pass null.
secretKey (SecretKey)A special key that was handed to you in ExecuteProtectedCodeAsync(Func<SecretKey, Task>)
cancellationToken (CancellationToken)A token that can be used to signal that the operation should be cancelled.
The auth tokens requested.
InvalidOperationExceptionAn invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager
RhinoAccountsExceptionAn error occurred during the authentication process. You may look at the specific subclass of the exception gain more insight as to why the operation failed.
OperationCanceledExceptionThe operation was cancelled, either by internal decisions or because the cancellationToken was cancelled.

GetAuthTokensAsync

#Since v7.0
public static Task<Tuple<IOpenIDConnectToken, IOAuth2Token>> GetAuthTokensAsync(string clientId, string clientSecret, SecretKey secretKey, CancellationToken cancellationToken)
Asynchronously retrieves auth tokens with the given criteria from the Rhino Accounts server.
Remarks: This method includes a default scope of 'openid', 'email', 'profile', and 'groups'. It should be suffifient for most workflows. This method shows the user a UI showing them the progress of the operation, and allows them to cancel it at any time. It also stores the retrieved tokens in a secure cache so they can be retrieved in the future by calling TryGetAuthTokens(string, SecretKey)
clientId (string)The unique id of the client registered in Rhino Accounts.
clientSecret (string)The secret of the client registered in Rhino Accounts
secretKey (SecretKey)A special key that was handed to you in ExecuteProtectedCodeAsync(Func<SecretKey, Task>)
cancellationToken (CancellationToken)A token that can be used to signal that the operation should be cancelled.
The auth tokens requested.
InvalidOperationExceptionAn invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager
RhinoAccountsExceptionAn error occurred during the authentication process. You may look at the specific subclass of the exception gain more insight as to why the operation failed.
OperationCanceledExceptionThe operation was cancelled, either by internal decisions or because the cancellationToken was cancelled.

RevokeAuthTokenAsync

#Since v7.0
public static Task RevokeAuthTokenAsync(IOAuth2Token oauth2Token, SecretKey secretKey, CancellationToken cancellationToken)
Invalidates/revokes an IOAuth2Token object from the Rhino Accounts server.
Remarks: If the OAuth 2 token is stored in the local cache, it will be removed from the cache as well.
oauth2Token (IOAuth2Token)The token to revoke.
secretKey (SecretKey)A special key that was handed to you in ExecuteProtectedCodeAsync(Func<SecretKey, Task>)
cancellationToken (CancellationToken)A token that can be used to signal that the operation should be cancelled.
InvalidOperationExceptionAn invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager
OperationCanceledExceptionThe operation was cancelled, either by internal decisions or because the cancellationToken was cancelled.

TryGetAuthTokens

#Since v7.0
public static Tuple<IOpenIDConnectToken, IOAuth2Token> TryGetAuthTokens(string clientId, IEnumerable<string> scope, SecretKey secretKey)
Attempts to return cached auth tokens that match the given criteria if any have been stored in cache.
clientId (string)The unique id of the client registered in Rhino Accounts.
scope (IEnumerable<string>)The scope desired for the tokens. Valid scope values can be found in the Rhino Accounts documentation.
secretKey (SecretKey)A special key that was handed to you in ExecuteProtectedCodeAsync(Func<SecretKey, Task>)
Cached tokens matching the exact criteria passed, or null if none can be found matching the criteria.
InvalidOperationExceptionAn invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager

TryGetAuthTokens

#Since v7.0
public static Tuple<IOpenIDConnectToken, IOAuth2Token> TryGetAuthTokens(string clientId, SecretKey secretKey)
Attempts to return cached auth tokens that match the given criteria if any have been stored in cache.
clientId (string)The unique id of the client registered in Rhino Accounts.
secretKey (SecretKey)A special key that was handed to you in ExecuteProtectedCodeAsync(Func<SecretKey, Task>)
Cached tokens matching the exact criteria passed, or null if none can be found matching the criteria.
InvalidOperationExceptionAn invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager

UpdateOpenIDConnectTokenAsync

#Since v7.0
public static Task<IOpenIDConnectToken> UpdateOpenIDConnectTokenAsync(IOpenIDConnectToken currentToken, IOAuth2Token oauth2Token, SecretKey secretKey, CancellationToken cancellationToken)
Updates an OpenID Connect token so that it contains the latest user information by contacting the Rhino Account's server userinfo endpoint using a compatible O
Remarks: If the OpenID Connect token is currently stored in the local cache, it will be updated to reflect the new token.
currentToken (IOpenIDConnectToken)The existing OpenID Connect token that you wish to updated with the latest user information.
oauth2Token (IOAuth2Token)A valid OAuth2 token used for authorization. The OAuth2 token must have been issued together with the OpenID Connect token passed or a RhinoAccountsAuthTokenMismatchException will be thrown.
secretKey (SecretKey)A special key that was handed to you in ExecuteProtectedCodeAsync(Func<SecretKey, Task>)
cancellationToken (CancellationToken)A token that can be used to signal that the operation should be cancelled.
The updated OpenIDConnectToken based on the original token passed to this method.
InvalidOperationExceptionAn invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager
RhinoAccountsExceptionAn error occurred during the authentication process. You may look at the specific subclass of the exception gain more insight as to why the operation failed.
OperationCanceledExceptionThe operation was cancelled, either by internal decisions or because the cancellationToken was cancelled.