public void Authenticate(IRestClient client, IRestRequest request) { request.AddHeader("Accept", "application/json"); if (!AuthenticationHelpers.IsAuthenticated(authToken)) { if (request.Resource != AuthenticationHelpers.AuthenticationPath) { authToken = AuthenticationHelpers.HandleBasicAuthentication(client, request, credentials); } } if (request.Resource == AuthenticationHelpers.ImpersonationPath) { AuthenticationHelpers.HandleImpersonation(request, credentials); } AuthenticationHelpers.ApplyTokenAuthentication(request, authToken); }
public void Authenticate(OrionApiClient client, Request request) { if (!AuthenticationHelpers.IsAuthenticated(authToken)) { if (request.RequestUri.ToString() != AuthenticationHelpers.AuthenticationPath && request.RequestUri.ToString() != AuthenticationHelpers.ImpersonationPath) { authToken = AuthenticationHelpers.HandleBasicAuthentication(client, request, apiCredentials); } } if (request.RequestUri.ToString() == AuthenticationHelpers.ImpersonationPath) { impToken = AuthenticationHelpers.HandleBasicAuthentication(client, request, serviceCredentials); AuthenticationHelpers.HandleImpersonation(request, impToken); } else { AuthenticationHelpers.ApplyTokenAuthentication(request, authToken); } }