std1.0.0-beta-7 SafeC docs

std :: http::oauth2

Struct std::OAuth2Token

#include <std/http/oauth2.h> source

struct OAuth2Token {
    struct String accessToken;
    struct String refreshToken;
    struct String tokenType;
    long long expiresIn;
}

Fields

§struct String accessTokensource
§struct String refreshTokensource

empty if the provider didn't return one

§struct String tokenTypesource

usually "Bearer"

§long long expiresInsource

seconds; 0 if not returned

Methods

§static struct OAuth2Token exchange_code( const &char tokenHost, unsigned short tokenPort, const &char tokenPath, const &char clientId, const &char clientSecret, const &char code, const &char redirectUri, ?&int ok, )source · definition

Exchanges an authorization code for tokens: POSTs 'grant_type=authorization_code&code=...&redirect_uri=...&client_id=... &client_secret=...' to '<tokenHost>:<tokenPort><tokenPath>'. *ok is set to 0 on any transport/HTTP-status/JSON-shape failure.

§static struct OAuth2Token refresh( const &char tokenHost, unsigned short tokenPort, const &char tokenPath, const &char clientId, const &char clientSecret, const &char refreshToken, ?&int ok, )source · definition

Exchanges a refresh token for a fresh access token ('grant_type=refresh_token&refresh_token=...&client_id=...&client_secret=...').

§void drop()source · definition

Releases the three owned strings.

§void free() consumesource · definition

= drop()