ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## 一、概述 开发平台的接口,分为两类,一类需要用户授权,一类不需要用户授权即可; ## 二、需用户授权接口 ### **获取授权码** API:/platform/oauth/connect/ > 参数中,redirect_uri需要特别注意,这个参数只要域名部分与应用注册的时候,授权域回调的域名配置一致,后面可以带参数或路径都可以; 实例: 授权域回调配置为:http://www.abc.com/ API拼凑的URL为: https://open.douyin.com/platform/oauth/connect/?client_key=aw0haqdl4fljkhaw&response_type=code&scope=user_info&redirect_uri=http://www.abc.com/api/system 访问上述地址,显示二维码,用抖音APP扫码后,得到授权,并重定向到http://www.abc.com/api/system 地址,且带上了?code=**** ### **获取access_token** API:/oauth/access_token/ 拿到授权码后,接着调用这个API,即可获取到access_token; API拼凑的URL为:https://open.douyin.com/oauth/access_token//?client_key=*****&client_secret=*****&grant_type=authorization_code&code=04a95b204ab1dc16DVAbpAIyyTbWZYxhX0QP ![](https://img.kancloud.cn/23/ae/23ae0f88853283713f6a5f38877f78f3_1366x140.png) 到这里,拿到access_token,就可以调用需要用户授权的接口了; ## 三、免用户授权需接口 ### **获取client_token** 获取接口调用的凭证client_access_token,用于调用**不需要用户授权**就可以调用的接口; API:/oauth/client_token/ API拼凑的URL为:https://open.douyin.com/oauth/client_token/?client_key=*****&client_secret=*****&grant_type=client_credential ![](https://img.kancloud.cn/ba/17/ba17c96c06c8b227a1ecb46bf55fcf36_1363x127.png) ## 四、调用接口实例 以获取用户信息(需要用户授权)为例说明: 1、获取到用户授权的code; 2、基于code,获取access_token(包含openId); 3、基于access_token和openId,获取用户信息即可; ![](https://img.kancloud.cn/ed/d2/edd26940db263faf651cc3a2494b70f2_1366x132.png) ## 五、总结 对于需用户授权的接口,调用过程为:获取code->换AccessToken->调用接口; 对于免用户授权的接口,调用过程为:获取ClientToken->调用接口;