Skip to content

GET GUEST TOKEN

ElbyFross edited this page Jan 15, 2020 · 2 revisions

Remarks

The guest token using to provide an authority session for not logoned client. The token required to performing an any query.

At the moment not allowed in query format because require token to backward connection.

Receiving of the guest token implemented via establishing of the BradcastServer that sending a guest tokens to any one who connecting.

Query processor

For handling a process of receiving a guest tokens the API provides a GuestTokenProcessor that fulfill the task in auto mode.

  • Implements the UniformQueries.Executable.Security.AuthQueryProcessor interface.

Examples

Manual requesting a guest token

The following example shows a way to request guest token via the GuestTokenProcessor.

C#

// Create the new processor.
var processor = new BaseQueries.GET_GUEST_TOKEN.GuestTokenProcessor();

// Sign up on a callback that occurs when auth operation is finished.
processor.ProcessingFinished += delegate (
    UniformQueries.Executable.QueryProcessor _,
    bool operationResult,
    object message)
{   
    // Handle result here.
};

// Request a guest token.
processor.TryToReciveTokenAsync(
    SERVER_IP,
    PIPE_NAME,
    AuthorityController.Session.Current.TerminationTokenSource.Token);
  • Where the SERVER_IP is an ip adress or the name of the computer into a local network.
  • Where the PIPE_NAME is a name of the named pipe started on the server.

Via the PartialAuthorizedInstruction

The easiest way comparing to manual is using the instructions defined in a RoutingTable. The partial authorized instructions implements an API to reduce amount of required actions from developer during fulfilling the task.

An idea of the PartialAuthorizedInstruction is that it holds and manages a guest token an allows to user perform some base queries not required logon.

The following example shows hot to request a guest token by using the PartialAuthorizedInstruction instance.

C#

// Request a token.
while (!await PAI.TryToGetGuestTokenAsync(CANCELATION_TOKEN))
{
    // Await 5s if failed and retry.
    await Task.Delay(5000, CANCELATION_TOKEN);
}
  • Where the PAI is the instance of the PartialAuthorizedInstruction where described routing to the server.
  • Where the CANCELATION_TOKEN is a token that would be used to stop the async operation.

Via the AuthorizedInstruction

In case if you use a full authorized routing instructions implemented by the AuthorizedInstruction then you no need to care about requesting a guest token.

The TryToLogon handler requests and waits for the token by itself.

But in case if you still have no a params to logon but already require the token the just use an previous example. The AuthorizedInstruction derived from the PartialAuthorizedInstruction so it has the same API.

Links

Related pages