mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	add missing file
This commit is contained in:
		
							
								
								
									
										23
									
								
								app/utils/baidu.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								app/utils/baidu.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
import { BAIDU_OATUH_URL } from "../constant";
 | 
			
		||||
/**
 | 
			
		||||
 * 使用 AK,SK 生成鉴权签名(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;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user