oauth.h
Go to the documentation of this file.
#ifndef COCOATWEET_OAUTH_OAUTH_H_
#define COCOATWEET_OAUTH_OAUTH_H_
#include <string>
#include <map>
#include <memory>
#include "key.h"
namespace CocoaTweet::OAuth {
class OAuth1 {
public:
enum AuthType { OAuth, Bearer };
OAuth1();
OAuth1(const Key _key);
std::map<std::string, std::string> signature(const std::map<std::string, std::string>& _param,
const std::string& _method,
const std::string& _url);
const std::string& generateBearerToken();
const std::string calculateAuthHeader(std::map<std::string, std::string> _bodyParam,
const std::string& _method, const std::string& _url);
const std::string nonce() const;
const std::string timestamp() const;
const std::string method() const;
const std::string version() const;
const Key key() const;
std::map<std::string, std::string> oauthParam() const;
std::string hmacSha1(std::string _key, std::string _data);
const std::string base64(const std::string& _raw);
private:
AuthType authType_;
Key key_;
const std::string SIGNATURE_METHOD_ = "HMAC-SHA1";
const std::string OAUTH_VERSION_ = "1.0";
static size_t curlCallback_(char* _ptr, size_t _size, size_t _nmemb, std::string* _stream) {
int realsize = _size * _nmemb;
_stream->append(_ptr, realsize);
return realsize;
}
};
} // namespace CocoaTweet::OAuth
#endif
CocoaTweet::OAuth::OAuth1::Bearer
@ Bearer
Definition: oauth.h:12
CocoaTweet::OAuth::OAuth1::oauthParam
std::map< std::string, std::string > oauthParam() const
Definition: oauth.cc:170
CocoaTweet::OAuth::OAuth1::generateBearerToken
const std::string & generateBearerToken()
Definition: oauth.cc:80
CocoaTweet::OAuth::OAuth1::OAuth
@ OAuth
Definition: oauth.h:12
CocoaTweet::OAuth::OAuth1
Definition: oauth.h:10
CocoaTweet::OAuth::OAuth1::timestamp
const std::string timestamp() const
Definition: oauth.cc:154
CocoaTweet::OAuth::OAuth1::signature
std::map< std::string, std::string > signature(const std::map< std::string, std::string > &_param, const std::string &_method, const std::string &_url)
Definition: oauth.cc:30
CocoaTweet::OAuth::OAuth1::nonce
const std::string nonce() const
Definition: oauth.cc:141
CocoaTweet::OAuth::OAuth1::key
const Key key() const
Definition: oauth.cc:166
CocoaTweet::OAuth::Key
Definition: key.h:8
CocoaTweet::OAuth::OAuth1::version
const std::string version() const
Definition: oauth.cc:162
CocoaTweet::OAuth::OAuth1::hmacSha1
std::string hmacSha1(std::string _key, std::string _data)
Definition: oauth.cc:210
key.h
CocoaTweet::OAuth::OAuth1::calculateAuthHeader
const std::string calculateAuthHeader(std::map< std::string, std::string > _bodyParam, const std::string &_method, const std::string &_url)
Definition: oauth.cc:49
CocoaTweet::OAuth::OAuth1::OAuth1
OAuth1()
Definition: oauth.cc:26
CocoaTweet::OAuth::OAuth1::AuthType
AuthType
Definition: oauth.h:12
CocoaTweet::OAuth::OAuth1::base64
const std::string base64(const std::string &_raw)
Definition: oauth.cc:180
CocoaTweet::OAuth::OAuth1::method
const std::string method() const
Definition: oauth.cc:158
CocoaTweet::OAuth
Definition: key.cc:7