ApplicationFactoryFindByApiKey Method |
Find an application using his API key, return null if not found.
Namespace:
AskiaPortalCmn
Assembly:
AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax public static IApplication FindByApiKey(
IContext context,
string apiKey
)
Public Shared Function FindByApiKey (
context As IContext,
apiKey As String
) As IApplication
public:
static IApplication^ FindByApiKey(
IContext^ context,
String^ apiKey
)
Parameters
- context
- Type: AskiaPortalCmnIContext
Context of execution. - apiKey
- Type: SystemString
API key of the application to find.
Return Value
Type:
IApplicationReturn null if the application was not found or if the user within the context doesn't have enough right to access it.
Examples
Find the application using his API key.
var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D"));
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
throw contextValidation.Exception;
}
var apiKey = "secret";
var app = ApplicationFactory.FindByApiKey(context, apiKey);
if (app != null)
{
Console.WriteLine("Application GUID={0} was found: {1}", app.Guid, app.Name);
}
else
{
Console.WriteLine("The specified application doesn't exist, or the current user within the context could not access it");
}
See Also