Bundle OAuth client (-lib net_server)
OAuthToken
OAuth token
Operations
- New
- FormatNewToken
- GetAccessToken
- GetExpiresIn
- GetRefreshToken
- GetScope
- IsExpired
- ReadTokenFormat
- Set
- ToString
FormatNewToken # function
Formats a new token
function : FormatNewToken(access_token:String, expires_in:Int) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| access_token | String | access token |
| expires_in | Int | expiration time |
Return
| Type | Description |
|---|---|
| String | formatted token string |
GetAccessToken #
Get access token
method : public : GetAccessToken() ~ StringReturn
| Type | Description |
|---|---|
| String | access token |
GetExpiresIn #
Get expiration time
method : public : GetExpiresIn() ~ IntReturn
| Type | Description |
|---|---|
| Int | expiration time |
GetRefreshToken #
Get refresh token
method : public : GetRefreshToken() ~ StringReturn
| Type | Description |
|---|---|
| String | refresh token |
IsExpired #
Returns true if the access token has expired
method : public : IsExpired() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if expired, false otherwise |
New # constructor
Constructor
New(access_token:String, refresh_token:String, expires_in:Int, scope:String)Parameters
| Name | Type | Description |
|---|---|---|
| access_token | String | access token |
| refresh_token | String | refresh token |
| expires_in | Int | expiration time |
| scope | String | token scope |
ReadTokenFormat # function
Reads and validates token format
function : ReadTokenFormat(secret_str:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| secret_str | String | secret string |
Return
| Type | Description |
|---|---|
| String | token if valid, Nil otherwise |
Set #
Sets the token values
method : public : Set(access_token:String, expires_in:Int, scope:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| access_token | String | access token |
| expires_in | Int | expiration time |
| scope | String | token scope |
ToString #
Get token as string
method : public : ToString() ~ StringReturn
| Type | Description |
|---|---|
| String | token as string |
Example
scopes := ["https://www.googleapis.com/auth/drive"];
client := System.IO.Net.OAuth.OAuthClient->New("client_secret.json", scopes);
token := client->GetToken();
if(token <> Nil) {
token->ToString()->PrintLine();
};