Authentication
We authenticate users of the Service using a bearer token. This token can be gained from Auth0 using your Massless Space, or Google account credentials.
- C#
var callCredentials = CallCredentials.FromInterceptor((context, metadata) =>{if (!string.IsNullOrEmpty(accessToken)){metadata.Add("Authorization", $"Bearer {accessToken}");}return Task.CompletedTask;});
Client and Session identification
We need to identify the client with an ID that is specific to that user and computer but doesn't change very frequently. We also need to identify which session the client is connected in, this can change as often as you like.
The following example code can be added to the CallCredentials.
- C#
if (!string.IsNullOrEmpty(sessionID)){metadata.Add("session_id", sessionID);}if (!string.IsNullOrEmpty(clientID)){metadata.Add("client_id", clientID);}
Version Checking
To validate the clients version, the client needs to send it in each call. This is easiest to put it in with all the other identification things in the headers.
Add the following code to the metadata to send the clients version.
- C#
if (!string.IsNullOrEmpty(semanticClientVersion.ToString())){metadata.Add("plugin_version", semanticClientVersion.ToString());}