![Picture of Jaisonb Picture of Jaisonb](/graphics/unknown.gif)
Jaisonb - 2015-02-11 15:56:11
Hey guys, so im working on authenticating with an API of a small company and need some help getting my code setup to authenticate with it. Here is the information i have and what i've got so far. Any help would be greatly appreciated, i've spent several days trying to figure this out and spending countless time trying different php oauth clients and cannot seem to get it to work. If you have ANY ideas it would be greatly appreciated. Even if i have to configure this client to work w/ it im ok w/ that.
Here is the basic Http post i need to make to their access token URL.
==============
POST /oauth/access_token HTTP/1.1
Accept: */*
Content-Type: application/x-www-form-urlencoded
Authorization:
OAuth oauth_consumer_key="a105eV7Wq6CyfnLfPHWIHlZfb96i4nLzvIBSUozn",
oauth_nonce="kKhMKRxUpgfJ09iArtraNGc9huPdBkZI7GBkAd4exa0",
oauth_signature="u2hPmgYlnZe7fLN3J0qPFQtl5tU%2FjLY%3D",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1390416425",
oauth_version="1.0"
x_auth_username=api%2buser%40yourcompany.com&x_auth_mode=client_auth&x_auth_password=secretword1
==============
And here is what i have so far to attempt to connect to this this. The API documentation is poor and this above POST info is about the best thing i have.
=================
$client = new oauth_client_class();
$client->server = '';
$client->debug = true;
$client->debug_output = true;
$client->request_token_url = 'https://api-company.com/oauth/access_token';
$client->get_token_with_api_key = $key;
$client->signature_method = 'HMAC-SHA1';
$client->url_parameters = array('x_auth_username' => $username, 'x_auth_mode' => 'client_auth', 'x_auth_password' => $password);
$client->redirect_uri = 'http://'.$_SERVER['HTTP_HOST'].dirname(strtok($_SERVER['REQUEST_URL'], '?')).'/something/likedis.php';
if(($success = $client->Initialize())) {
if(($success = $client->Process())) {
if (strlen($client->access_token)) {
$client->access_token;
echo "It Worked";
} elseif (strlen($client->authorization_error)) {
$client->error = $client->authorization_error;
$success = $client->Finalize($success);
echo $client->error;
} else {
echo $client->error;
//echo $client->Output();
}
} else {
echo "Error: " . $client->error. "\n";
var_dump($client);
}
} else {
echo "Problem Initializing";
}
==============
Currently im receiving a "the dialog URL is not defined for this server" error. trying to debug this. however once i figure that out im sure there will be something else i may be missing.