@microsoft/teams.api
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t
77 lines (75 loc) • 2.21 kB
JavaScript
import qs from 'qs';
import { Client } from '@microsoft/teams.common';
import { mergeApiClientSettings } from '../api-client-settings.mjs';
const USER_TOKEN_ENDPOINTS = {
GET_TOKEN: "api/usertoken/GetToken",
GET_AAD_TOKENS: "api/usertoken/GetAadTokens",
GET_STATUS: "api/usertoken/GetTokenStatus",
SIGN_OUT: "api/usertoken/SignOut",
EXCHANGE: "api/usertoken/exchange"
};
class UserTokenClient {
get http() {
return this._http;
}
set http(v) {
this._http = v;
}
_http;
_apiClientSettings;
constructor(options, apiClientSettings, cloud) {
if (!options) {
this._http = new Client();
} else if ("request" in options) {
this._http = options;
} else {
this._http = new Client(options);
}
this._apiClientSettings = mergeApiClientSettings(apiClientSettings, cloud);
}
async get(params) {
const q = qs.stringify(params);
const res = await this.http.get(
`${this._apiClientSettings.oauthUrl}/${USER_TOKEN_ENDPOINTS.GET_TOKEN}?${q}`
);
return res.data;
}
async getAad(params) {
const q = qs.stringify(params);
const res = await this.http.post(
`${this._apiClientSettings.oauthUrl}/${USER_TOKEN_ENDPOINTS.GET_AAD_TOKENS}?${q}`,
params
);
return res.data;
}
async getStatus(params) {
const q = qs.stringify(params);
const res = await this.http.get(
`${this._apiClientSettings.oauthUrl}/${USER_TOKEN_ENDPOINTS.GET_STATUS}?${q}`
);
return res.data;
}
async signOut(params) {
const q = qs.stringify(params);
const res = await this.http.delete(
`${this._apiClientSettings.oauthUrl}/${USER_TOKEN_ENDPOINTS.SIGN_OUT}?${q}`,
{ data: params }
);
return res.data;
}
async exchange(params) {
const q = qs.stringify({
userId: params.userId,
connectionName: params.connectionName,
channelId: params.channelId
});
const res = await this.http.post(
`${this._apiClientSettings.oauthUrl}/${USER_TOKEN_ENDPOINTS.EXCHANGE}?${q}`,
params.exchangeRequest
);
return res.data;
}
}
export { USER_TOKEN_ENDPOINTS, UserTokenClient };
//# sourceMappingURL=token.mjs.map
//# sourceMappingURL=token.mjs.map