Sends a POST to get a Dwolla OAuth2 access token. Note: This is a simple POST to get a simple response that contains the OAuth2 access token. Fetching OAuth2 access tokens for Dwolla do not involve displaying a browser (it is not 3-legged OAuth2).
curl -X POST https://sandbox.dwolla.com/oauth/v2/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=DWOLLA_KEY" \
-d "client_secret=DWOLLA_SECRET" \
-d "grant_type=client_credentials"
use chilkat();
$rest = chilkat::CkRest->new();
# URL: https://sandbox.dwolla.com/oauth/v2/token
$bTls = 1;
$port = 443;
$bAutoReconnect = 1;
$success = $rest->Connect("sandbox.dwolla.com",$port,$bTls,$bAutoReconnect);
if ($success != 1) {
print "ConnectFailReason: " . $rest->get_ConnectFailReason() . "\r\n";
print $rest->lastErrorText() . "\r\n";
exit;
}
$rest->AddQueryParam("client_id","DWOLLA_KEY");
$rest->AddQueryParam("client_secret","DWOLLA_SECRET");
$rest->AddQueryParam("grant_type","client_credentials");
$strResponseBody = $rest->fullRequestFormUrlEncoded("POST","/oauth/v2/token");
if ($rest->get_LastMethodSuccess() != 1) {
print $rest->lastErrorText() . "\r\n";
exit;
}
$jsonResponse = chilkat::CkJsonObject->new();
$jsonResponse->Load($strResponseBody);
$access_token = $jsonResponse->stringOf("access_token");
$token_type = $jsonResponse->stringOf("token_type");
$expires_in = $jsonResponse->IntOf("expires_in");
{
"access_token": "x0M8TCnDUTuMhA2Gp7dZyAYL3iORQZYzLlZOn7EximEGSrddpC",
"token_type": "bearer",
"expires_in": 3604
}