ImFusion SDK 4.3
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 informations 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)
 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()

static 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()

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

Parses an AccessToken from an OAuth2 JSON response.

Fills all fields that are present in the JSON, except username and password.

Member Data Documentation

◆ refreshToken

std::string refreshToken

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

Might be empty if no refresh token is available.

◆ 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 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 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:
Search Tab / S to search, Esc to close