IRhinoAccountsManager
Performs various Rhino Accounts-related tasks.
Methods
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.
Parameters:
| 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. |
Exceptions:
| RhinoAccountsOperationInProgressException | Another operation is already in progress. |
ExecuteProtectedCodeAsync
#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.
Parameters:
| 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. |
Exceptions:
| RhinoAccountsOperationInProgressException | Another operation is already in progress. |
GetAuthTokensAsync
#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.
Parameters:
| 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. |
Returns: The auth tokens requested.
Exceptions:
| InvalidOperationException | An invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager |
| RhinoAccountsException | An 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. |
| OperationCanceledException | The operation was cancelled, either by internal decisions or because the cancellationToken was cancelled. |
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)
Parameters:
| 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. |
Returns: The auth tokens requested.
Exceptions:
| InvalidOperationException | An invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager |
| RhinoAccountsException | An 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. |
| OperationCanceledException | The operation was cancelled, either by internal decisions or because the cancellationToken was cancelled. |
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.
Parameters:
| 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. |
Exceptions:
| InvalidOperationException | An invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager |
| OperationCanceledException | The operation was cancelled, either by internal decisions or because the cancellationToken was cancelled. |
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.
Parameters:
| 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>) |
Returns: Cached tokens matching the exact criteria passed, or null if none can be found matching the criteria.
Exceptions:
| InvalidOperationException | An invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager |
Attempts to return cached auth tokens that match the given criteria if any have been stored in cache.
Parameters:
| 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>) |
Returns: Cached tokens matching the exact criteria passed, or null if none can be found matching the criteria.
Exceptions:
| InvalidOperationException | An invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager |
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.
Parameters:
| 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. |
Returns: The updated OpenIDConnectToken based on the original token passed to this method.
Exceptions:
| InvalidOperationException | An invalid secretKey was passed, or the assembly is not allowed to call methods from IRhinoAccountsManager |
| RhinoAccountsException | An 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. |
| OperationCanceledException | The operation was cancelled, either by internal decisions or because the cancellationToken was cancelled. |