You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
555 B
TypeScript

9 months ago
import { BAIDU_OATUH_URL } from "../constant";
/**
* 使 AKSK Access Token
* @return
*/
export async function getAccessToken(
clientId: string,
clientSecret: string,
): Promise<{
access_token: string;
expires_in: number;
error?: number;
}> {
const res = await fetch(
`${BAIDU_OATUH_URL}?grant_type=client_credentials&client_id=${clientId}&client_secret=${clientSecret}`,
{
method: "POST",
mode: "cors",
},
);
const resJson = await res.json();
return resJson;
}