access_tokenの再発行が出来るように
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
#include <cocoatweet/authentication/bearer.h>
|
#include <cocoatweet/authentication/bearer.h>
|
||||||
#include <cocoatweet/authentication/plain.h>
|
#include <cocoatweet/authentication/plain.h>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace CocoaTweet::API {
|
namespace CocoaTweet::API {
|
||||||
API::API(CocoaTweet::Authentication::Key _key) {
|
API::API(CocoaTweet::Authentication::Key _key) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void AccessToken::oauthToken(const CocoaTweet::API::Model::OAuthToken _token) {
|
|||||||
|
|
||||||
const CocoaTweet::API::Model::OAuthToken AccessToken::process(
|
const CocoaTweet::API::Model::OAuthToken AccessToken::process(
|
||||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
||||||
auto key = oauth_.lock()->key();
|
auto key = _oauth.lock()->key();
|
||||||
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||||
key.accessToken(oauthToken_.oauthToken());
|
key.accessToken(oauthToken_.oauthToken());
|
||||||
key.accessTokenSecret(oauthToken_.oauthTokenSecret());
|
key.accessTokenSecret(oauthToken_.oauthTokenSecret());
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#include <cocoatweet/api/oauth1/invalidateToken.h>
|
||||||
|
#include <cocoatweet/util/util.h>
|
||||||
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
|
#include <cocoatweet/authentication/oauth.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace CocoaTweet::API::OAuth1 {
|
||||||
|
InvalidateToken::InvalidateToken() {
|
||||||
|
contentType_ = "application/x-www-form-urlencoded";
|
||||||
|
url_ = "https://api.twitter.com/1.1/oauth/invalidate_token";
|
||||||
|
}
|
||||||
|
|
||||||
|
const CocoaTweet::API::Model::OAuthToken InvalidateToken::process(
|
||||||
|
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
||||||
|
auto key = _oauth.lock()->key();
|
||||||
|
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||||
|
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||||
|
CocoaTweet::API::Model::OAuthToken oauthToken;
|
||||||
|
HttpPost::process(oauth, [&oauthToken](const std::string& _rcv) {
|
||||||
|
std::cout << _rcv << std::endl;
|
||||||
|
auto j = nlohmann::json::parse(_rcv);
|
||||||
|
oauthToken.oauthToken(j["access_token"]);
|
||||||
|
});
|
||||||
|
return oauthToken;
|
||||||
|
}
|
||||||
|
} // namespace CocoaTweet::API::OAuth1
|
||||||
@@ -1,4 +1,17 @@
|
|||||||
#ifndef COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_
|
#ifndef COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_
|
||||||
#define COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_
|
#define COCOATWEET_API_OAUTH1_INVALIDATETOKEN_H_
|
||||||
|
|
||||||
|
#include <cocoatweet/api/interface/httpPost.h>
|
||||||
|
#include <cocoatweet/api/model/oauthToken.h>
|
||||||
|
namespace CocoaTweet::API::OAuth1 {
|
||||||
|
class InvalidateToken : public CocoaTweet::API::Interface::HttpPost {
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
InvalidateToken();
|
||||||
|
|
||||||
|
const CocoaTweet::API::Model::OAuthToken process(
|
||||||
|
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth);
|
||||||
|
};
|
||||||
|
} // namespace CocoaTweet::API::OAuth1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -34,4 +34,12 @@ const CocoaTweet::API::Model::OAuthToken OAuth::accessToken(
|
|||||||
accessToken.oauthVerifier(_verifier);
|
accessToken.oauthVerifier(_verifier);
|
||||||
return accessToken.process(oauth_);
|
return accessToken.process(oauth_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CocoaTweet::API::Model::OAuthToken OAuth::invalidateToken() const {
|
||||||
|
// auto key = oauth_.lock()->key();
|
||||||
|
// key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||||
|
// auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||||
|
CocoaTweet::API::OAuth1::InvalidateToken invalidateToken;
|
||||||
|
return invalidateToken.process(oauth_);
|
||||||
|
}
|
||||||
} // namespace CocoaTweet::API::OAuth1
|
} // namespace CocoaTweet::API::OAuth1
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <cocoatweet/api/oauth1/accessToken.h>
|
#include <cocoatweet/api/oauth1/accessToken.h>
|
||||||
#include <cocoatweet/api/oauth1/requestToken.h>
|
#include <cocoatweet/api/oauth1/requestToken.h>
|
||||||
#include <cocoatweet/api/oauth1/authorize.h>
|
#include <cocoatweet/api/oauth1/authorize.h>
|
||||||
|
#include <cocoatweet/api/oauth1/invalidateToken.h>
|
||||||
#include <cocoatweet/api/model/oauthToken.h>
|
#include <cocoatweet/api/model/oauthToken.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -25,6 +26,7 @@ public:
|
|||||||
const std::string authorize(const CocoaTweet::API::Model::OAuthToken _oauthToken) const;
|
const std::string authorize(const CocoaTweet::API::Model::OAuthToken _oauthToken) const;
|
||||||
const CocoaTweet::API::Model::OAuthToken accessToken(
|
const CocoaTweet::API::Model::OAuthToken accessToken(
|
||||||
const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const;
|
const CocoaTweet::API::Model::OAuthToken _oauthToken, const std::string _verifier) const;
|
||||||
|
const CocoaTweet::API::Model::OAuthToken invalidateToken() const;
|
||||||
};
|
};
|
||||||
} // namespace CocoaTweet::API::OAuth1
|
} // namespace CocoaTweet::API::OAuth1
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void RequestToken::oauthCallback(const std::string& _oauthCallback) {
|
|||||||
|
|
||||||
CocoaTweet::API::Model::OAuthToken RequestToken::process(
|
CocoaTweet::API::Model::OAuthToken RequestToken::process(
|
||||||
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
std::weak_ptr<CocoaTweet::Authentication::AuthenticatorBase> _oauth) {
|
||||||
auto key = oauth_.lock()->key();
|
auto key = _oauth.lock()->key();
|
||||||
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
key.authType(CocoaTweet::Authentication::Key::AUTH_TYPE::OAUTH10A);
|
||||||
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
auto oauth = std::make_shared<CocoaTweet::Authentication::OAuth1>(key);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user