ImFusion C++ SDK 4.5.0
ImFusion::Network::AccessToken Struct Reference

#include <ImFusion/Base/AccessToken.h>

Represents an access token for a HTTP server. More...

Detailed Description

Represents an access token for a HTTP server.

Also holds all information to refresh the token.

Static Public Member Functions

static AccessToken fromUsernameAndPassword (const std::string &username, const std::string &password)
 Generates an AccessToken from a username and password according to HTTP Basic Auth.
static Utils::Expected< AccessToken, std::stringfromOAuth2 (const std::string &json, const Filesystem::Url &tokenEndpoint, const std::string &clientId, const std::string &oldRefreshToken="")
 Parses an AccessToken from an OAuth2 JSON response.

Public Attributes

std::string accessToken
 The actual access token for the API.
std::string refreshToken
 A token that can be used to obtain a new access token.
std::string scheme
 Auth scheme of the token, e.g. "Basic" or "Bearer".
std::chrono::time_point< std::chrono::system_clockexpiresAfter
 Timepoint after which the accessToken is no longer valid.
std::chrono::time_point< std::chrono::system_clockrefreshExpiresAfter
 Same as expiresAfter but for the refreshToken.
std::string username
 without a refresh token, the username and password can be used to get a new token.
std::string password
std::string tokenEndpoint
 The url from where the token was requested.
std::string clientId
 The oauth client_id that was used to get the token.

Member Function Documentation

◆ fromUsernameAndPassword()

AccessToken ImFusion::Network::AccessToken::fromUsernameAndPassword ( const std::string & username,
const std::string & password )
static

Generates an AccessToken from a username and password according to HTTP Basic Auth.

This will only fill the accessToken, username and password fields. All other fields will remain empty.

◆ fromOAuth2()

Utils::Expected< AccessToken, std::string > ImFusion::Network::AccessToken::fromOAuth2 ( const std::string & json,
const Filesystem::Url & tokenEndpoint,
const std::string & clientId,
const std::string & oldRefreshToken = "" )
static

Parses an AccessToken from an OAuth2 JSON response.

Fills all fields that are present in the JSON, except username and password. Optionally, the oldRefreshToken will be used if the refreshToken is absent in the response.

Member Data Documentation

◆ refreshToken

std::string ImFusion::Network::AccessToken::refreshToken

A token that can be used to obtain a new access token.

Might be empty if no refresh token is available.

◆ expiresAfter

std::chrono::time_point<std::chrono::system_clock> ImFusion::Network::AccessToken::expiresAfter

Timepoint after which the accessToken is no longer valid.

Note that this is not entirely accurate and the token might actually expire a few seconds earlier.

◆ username

std::string ImFusion::Network::AccessToken::username

without a refresh token, the username and password can be used to get a new token.

Will be empty if the user didn't login with username and password.

◆ tokenEndpoint

std::string ImFusion::Network::AccessToken::tokenEndpoint

The url from where the token was requested.

Can also be used to request a refresh token.


The documentation for this struct was generated from the following file:
  • ImFusion/Base/AccessToken.h
Search Tab / S to search, Esc to close