NUGU SDK Linux  1.7.6
NuguClientKit::NuguAuth Class Reference

NuguAuth. More...

#include <nugu_auth.hh>

Public Member Functions

bool discovery (const std::function< void(bool success, const struct AuthResponse *response)> &cb)
 Async OAuth2 discovery to get OAuth2 end-point and server url. More...
 
bool discovery (struct AuthResponse *response=nullptr)
 OAuth2 discovery to get OAuth2 end-point and server url. More...
 
std::string generateAuthorizeUrl (const std::string &device_serial)
 Get OAuth2 authorization url. More...
 
NuguTokengetAuthorizationCodeToken (const std::string &code, const std::string &device_serial, struct AuthResponse *response=nullptr)
 Get the token using authorization code (token exchange) More...
 
NuguTokengetClientCredentialsToken (const std::string &device_serial, struct AuthResponse *response=nullptr)
 Get the token using client credentials. More...
 
std::string getGatewayRegistryUri ()
 Get uri for device gateway registry. More...
 
time_t getRemainExpireTime (const NuguToken *token, time_t base_time=0)
 Get remaining expiration time based on base_time. More...
 
std::string getTemplateServerUri ()
 Get uri for template server. More...
 
bool isExpired (const NuguToken *token, time_t base_time=0)
 Check the token is expired or not. More...
 
bool isSupport (const GrantType &gtype)
 Check whether the requested grant type is supported for the client. More...
 
 NuguAuth (const NuguDeviceConfig &config)
 
bool parseAccessToken (NuguToken *token)
 Parsing the JWT access_token and fill the token information. More...
 
bool refresh (NuguToken *token, const std::string &device_serial="", struct AuthResponse *response=nullptr)
 Refresh the access_token and update the token information. More...
 

Detailed Description

Member Function Documentation

◆ discovery() [1/2]

bool NuguClientKit::NuguAuth::discovery ( struct AuthResponse response = nullptr)

OAuth2 discovery to get OAuth2 end-point and server url.

Parameters
[out]responseHTTP response data
Returns
result
Return values
truesuccess
falsefailure

◆ discovery() [2/2]

bool NuguClientKit::NuguAuth::discovery ( const std::function< void(bool success, const struct AuthResponse *response)> &  cb)

Async OAuth2 discovery to get OAuth2 end-point and server url.

Parameters
[in]cbcallback function to receive response
Returns
result
Return values
truesuccess
falsefailure

◆ isSupport()

bool NuguClientKit::NuguAuth::isSupport ( const GrantType gtype)

Check whether the requested grant type is supported for the client.

Parameters
[in]gtypegrant type
Returns
result
Return values
truesupported
falsenot supported

◆ generateAuthorizeUrl()

std::string NuguClientKit::NuguAuth::generateAuthorizeUrl ( const std::string &  device_serial)

Get OAuth2 authorization url.

Parameters
[in]device_serialdevice serial info
Returns
std::string authorization url

◆ getAuthorizationCodeToken()

NuguToken* NuguClientKit::NuguAuth::getAuthorizationCodeToken ( const std::string &  code,
const std::string &  device_serial,
struct AuthResponse response = nullptr 
)

Get the token using authorization code (token exchange)

Parameters
[in]codeOAuth2 authorization code
[in]device_serialdevice serial info
[out]responseHTTP response data
Returns
NuguToken* token information

◆ getClientCredentialsToken()

NuguToken* NuguClientKit::NuguAuth::getClientCredentialsToken ( const std::string &  device_serial,
struct AuthResponse response = nullptr 
)

Get the token using client credentials.

Parameters
[in]device_serialdevice serial info
[out]responseHTTP response data
Returns
NuguToken* token information

◆ parseAccessToken()

bool NuguClientKit::NuguAuth::parseAccessToken ( NuguToken token)

Parsing the JWT access_token and fill the token information.

Parameters
[in,out]tokentoken information
Returns
true parsing success
false parsing failed

◆ refresh()

bool NuguClientKit::NuguAuth::refresh ( NuguToken token,
const std::string &  device_serial = "",
struct AuthResponse response = nullptr 
)

Refresh the access_token and update the token information.

Parameters
[in,out]tokentoken information
[in]device_serialdevice serial info
[out]responseHTTP response data
Returns
true success
false failure

◆ isExpired()

bool NuguClientKit::NuguAuth::isExpired ( const NuguToken token,
time_t  base_time = 0 
)

Check the token is expired or not.

Parameters
token[in]token information
base_time[in]base timestamp(secs), '0' means the current timestamp
Returns
true token is expired
false token is not expired

◆ getRemainExpireTime()

time_t NuguClientKit::NuguAuth::getRemainExpireTime ( const NuguToken token,
time_t  base_time = 0 
)

Get remaining expiration time based on base_time.

Parameters
token[in]token information
base_time[in]base timestamp(secs), '0' means the current timestamp
Returns
time_t remain secs. '0' means the token is expired

◆ getGatewayRegistryUri()

std::string NuguClientKit::NuguAuth::getGatewayRegistryUri ( )

Get uri for device gateway registry.

Returns
std::string uri

◆ getTemplateServerUri()

std::string NuguClientKit::NuguAuth::getTemplateServerUri ( )

Get uri for template server.

Returns
std::string uri

The documentation for this class was generated from the following file: