Java实现抖音开放平台二维码授权功能 |
您所在的位置:网站首页 › 抖音app扫码授权 › Java实现抖音开放平台二维码授权功能 |
一、在yml中添加抖音开放平台的账号基本信息 # 抖音开放平台配置信息 dy: clientKey: #抖音开放平台key clientSecret: #抖音开放平台密钥 scope: data.external.user,data.external.item,fans.data,user_info,renew_refresh_token,data.external.user#需要用户开放的权限 responseType: code#填写code就行 redirectUri: #扫码之后的回调地址 state: false
三、二维码url拼接 Api @Resource private DouYinService douYinService; @GetMapping("code") public void Code(HttpServletRequest request, HttpServletResponse response) throws IOException { String requestUrl = douYinService.qrcodeAuth(); System.out.println("回调url:"+requestUrl); response.sendRedirect(requestUrl); }service @Autowired DouYinConfig douYinCode; Logger logger = LoggerFactory.getLogger(getClass()); public String qrcodeAuth() { String code = "https://open.douyin.com/platform/oauth/connect/?client_key=" + douYinCode.getClientKey() + "&response_type="+douYinCode.getResponseType()+"&scope="+douYinCode.getScope()+"&redirect_uri="+douYinCode.getRedirectUri()+"&state="+douYinCode.getState(); logger.info("qrConnect requestUrl=" + code); return code; }四、访问url效果如下 五、其他的授权调用都是通过扫码后得到的code(每次扫码得到一个code,每个code只能使用一次),之后使用code得到token,使用得到token中的信息实现授权功能的数据爬取。 六、得到token的url: String token_url = "https://open.douyin.com/oauth/access_token/?client_key=" + clientKey + "&client_secret=" + clientSecret + "&code="+code+"&grant_type=authorization_code"; 七、其他的授权后的数据爬取参考 https://open.douyin.com/platform/doc/6848806527751489550 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |