【发布时间】:2020-11-09 22:22:16
【问题描述】:
我尝试使用访问令牌从我的 Qt 应用程序实现 GitHub 身份验证。通过提供 URL(在我的例子中是 https://api.github.com/notifications)和我在 GitHub 上生成的访问令牌(Settings/Developer settings/Personal access tokens)https://github.com/settings/tokens,我可以使用 Postman 毫无问题地连接到 GitHub。现在我想使用 Qt 做同样的事情,但找不到如何做到这一点的示例。 Qt 文档中有 Reddit(https://doc.qt.io/qt-5/qtnetworkauth-redditclient-example.html) 的示例,但它使用了一些重定向算法,而不是访问令牌:
auto replyHandler = new QOAuthHttpServerReplyHandler(1337, this);
oauth2.setReplyHandler(replyHandler);
oauth2.setAuthorizationUrl(QUrl("https://www.reddit.com/api/v1/authorize"));
oauth2.setAccessTokenUrl(QUrl("https://www.reddit.com/api/v1/access_token"));
我不知道如何使用提供的访问令牌来做同样的事情。
【问题讨论】: