@azure-rest/ai-translation-text
Version:
An isomorphic client library for the Azure Cognitive Translator Service
39 lines • 1.53 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const APIM_KEY_HEADER_NAME = "Ocp-Apim-Subscription-Key";
const APIM_REGION_HEADER_NAME = "Ocp-Apim-Subscription-Region";
const APIM_RESOURCE_ID = "Ocp-Apim-ResourceId";
export const DEFAULT_SCOPE = "https://cognitiveservices.azure.com/.default";
export class TranslatorAuthenticationPolicy {
constructor(credential) {
this.name = "TranslatorAuthenticationPolicy";
this.credential = credential;
}
sendRequest(request, next) {
request.headers.set(APIM_KEY_HEADER_NAME, this.credential.key);
request.headers.set(APIM_REGION_HEADER_NAME, this.credential.region);
return next(request);
}
}
export class TranslatorAzureKeyAuthenticationPolicy {
constructor(credential) {
this.name = "TranslatorAzureKeyAuthenticationPolicy";
this.credential = credential;
}
sendRequest(request, next) {
request.headers.set(APIM_KEY_HEADER_NAME, this.credential.key);
return next(request);
}
}
export class TranslatorTokenCredentialAuthenticationPolicy {
constructor(credential) {
this.name = "TranslatorTokenCredentialAuthenticationPolicy";
this.credential = credential;
}
sendRequest(request, next) {
request.headers.set(APIM_REGION_HEADER_NAME, this.credential.region);
request.headers.set(APIM_RESOURCE_ID, this.credential.azureResourceId);
return next(request);
}
}
//# sourceMappingURL=authenticationCustomized.js.map