mastodonpp
0.5.4
|
Simplifies obtaining an OAuth 2.0 Bearer Access Token. More...
#include <mastodonpp/instance.hpp>
Public Member Functions | |
ObtainToken (Instance &instance) | |
Constructor. More... | |
answer_type | step_1 (string_view client_name, string_view scopes, string_view website) |
Creates an application via /api/v1/apps . More... | |
answer_type | step_2 (string_view code) |
Creates a token via /oauth/token . More... | |
Public Member Functions inherited from mastodonpp::CURLWrapper | |
CURLWrapper () | |
Initializes curl and sets up connection. More... | |
CURLWrapper (const CURLWrapper &) | |
Copy constructor. Does the same as the Constructor. More... | |
CURLWrapper (CURLWrapper &&other) noexcept=delete | |
Move constructor. More... | |
virtual | ~CURLWrapper () noexcept |
Cleans up curl and connection. More... | |
CURLWrapper & | operator= (const CURLWrapper &other)=delete |
Copy assignment operator. More... | |
CURLWrapper & | operator= (CURLWrapper &&other) noexcept=delete |
Move assignment operator. More... | |
CURL * | get_curl_easy_handle () |
Returns pointer to the CURL easy handle. More... | |
string | escape_url (const string_view url) const |
URL encodes the given string. More... | |
string | unescape_url (const string_view url) const |
URL decodes the given string. More... | |
void | setup_connection_properties (string_view proxy, string_view access_token, string_view cainfo, string_view useragent) |
Set some properties of the connection. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from mastodonpp::CURLWrapper | |
answer_type | make_request (const http_method &method, string uri, const parametermap ¶meters) |
Make a HTTP request. More... | |
string & | get_buffer () |
Returns a reference to the buffer libcurl writes into. More... | |
void | cancel_stream () |
Cancel the stream. More... | |
virtual void | set_proxy (string_view proxy) |
Set the proxy to use. More... | |
void | set_access_token (string_view access_token) |
Set OAuth 2.0 Bearer Access Token. More... | |
virtual void | set_cainfo (string_view path) |
Set path to Certificate Authority (CA) bundle. More... | |
virtual void | set_useragent (string_view useragent) |
Sets the User-Agent. More... | |
Protected Attributes inherited from mastodonpp::CURLWrapper | |
mutex | _buffer_mutex |
Mutex for get_buffer a.k.a. _curl_buffer_body. More... | |
Simplifies obtaining an OAuth 2.0 Bearer Access Token.
Example:
|
inlineexplicit |
Constructor.
answer_type mastodonpp::Instance::ObtainToken::step_1 | ( | string_view | client_name, |
string_view | scopes, | ||
string_view | website | ||
) |
Creates an application via /api/v1/apps
.
The body
of the returned answer contains only the URI, not the whole JSON response.
client_name | The name of your application. |
scopes | Space separated list of scopes. Defaults to “read” if empty. |
website | The URI to the homepage of your application. Can be an empty string. |
answer_type mastodonpp::Instance::ObtainToken::step_2 | ( | string_view | code | ) |
Creates a token via /oauth/token
.
The body
of the returned answer contains only the access token, not the whole JSON response.
The access token will be set in the Instance you initialized this ObtainToken with.
code | The authorization code you got from the user. |