// Generate the header value / auth token we need to provide for access validation to the translation service private static string GenerateAuthToken(string client_id = null, string client_secret = null) { AdmAccessToken admToken; string headerValue; // Checks if azure login info is overriden client_id = client_id == null ? azure_client_id : client_id; client_secret = client_secret == null ? azure_client_secret : client_secret; AdmAuthentication admAuth = new AdmAuthentication(client_id, client_secret); admToken = admAuth.GetAccessToken(); DateTime tokenReceived = DateTime.Now; // Create a header with the access_token property of the returned token headerValue = "Bearer " + admToken.access_token; // Return header return headerValue; }
public static String Execute(String text, String lang, String client_id = null, String client_secret = null) { AdmAccessToken admToken; string headerValue; // Checks if azure login info is overriden client_id = client_id == null ? azure_client_id : client_id; client_secret = client_secret == null ? azure_client_secret : client_secret; AdmAuthentication admAuth = new AdmAuthentication(client_id, client_secret); admToken = admAuth.GetAccessToken(); DateTime tokenReceived = DateTime.Now; // Create a header with the access_token property of the returned token headerValue = "Bearer " + admToken.access_token; return TranslateMethod(headerValue, text, lang); }