在哪里可以找到可以通过客户端SDK生成Google API访问令牌的Java样本?

发布于 2025-01-30 10:35:53 字数 193 浏览 3 评论 0原文

this 视频使用http提到的 id,客户秘密和刷新令牌。但是,我似乎找不到相应的客户端CALL文档或示例代码。有人可以指出我是否存在?谢谢。

This video mentioned using http get to retrieve google API access token given client id, client secret and refresh token. However, I don't seem to find the corresponding client sdk call documentation, nor sample code, for that. Can someone please point me to that if exists? Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

触ぅ动初心 2025-02-06 10:35:53

终于我发现了这项工作:

    JSONObject json = new JSONObject();

    json.put("client_id", clientId);
    json.put("client_secret", clientSecret);
    json.put("refresh_token", refreshToken);
    json.put("type", "authorized_user");

    InputStream stream = new ByteArrayInputStream(json.toString().getBytes(StandardCharsets.UTF_8));

    var credentials = GoogleCredentials.fromStream(stream);

    accessToken = credentials.refreshAccessToken();

Finally I found this works:

    JSONObject json = new JSONObject();

    json.put("client_id", clientId);
    json.put("client_secret", clientSecret);
    json.put("refresh_token", refreshToken);
    json.put("type", "authorized_user");

    InputStream stream = new ByteArrayInputStream(json.toString().getBytes(StandardCharsets.UTF_8));

    var credentials = GoogleCredentials.fromStream(stream);

    accessToken = credentials.refreshAccessToken();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文