Function
getAccessToken
(
clientId: string,
clientSecret: string,
)
Source from the content-addressed store, hash-verified
| 4 | * @return 鉴权签名信息 |
| 5 | */ |
| 6 | export async function getAccessToken( |
| 7 | clientId: string, |
| 8 | clientSecret: string, |
| 9 | ): Promise<{ |
| 10 | access_token: string; |
| 11 | expires_in: number; |
| 12 | error?: number; |
| 13 | }> { |
| 14 | const res = await fetch( |
| 15 | `${BAIDU_OATUH_URL}?grant_type=client_credentials&client_id=${clientId}&client_secret=${clientSecret}`, |
| 16 | { |
| 17 | method: "POST", |
| 18 | mode: "cors", |
| 19 | }, |
| 20 | ); |
| 21 | const resJson = await res.json(); |
| 22 | return resJson; |
| 23 | } |
Tested by
no test coverage detected