Method Web.Auth.OAuth2.Client()->request_access_token()


Method request_access_token

string request_access_token(string code, void|function(bool, string:void) async_cb)

Description

Requests an access token.

Throws

An error if the access token request fails.

Parameter code

The code returned from the authorization page via get_auth_uri().

Parameter async_cb

If given an async request will be made and this function will be called when the request is finished. The first argument passed to the callback will be true or false depending on if the request was successfull or not. The second argument will be a string. If the request failed it will be an error message. If it succeeded it will be the result as a string encoded with encode_value().

Returns

If OK a Pike encoded mapping (i.e it's a string) is returned which can be used to populate an Base object at a later time.

The mapping looks like

"access_token" : string
"expires" : int
"created" : int
"refresh_token" : string
"token_type" : string

Depending on the authorization service it might also contain more members.