PHP Classes

Access this type of OAuth 1.0a api? [Help needed!! please ]

Recommend this page to a friend!

      PHP OAuth Library  >  PHP OAuth Library package blog  >  How to Implement PHP ...  >  All threads  >  Access this type of OAuth 1.0a api?...  >  (Un) Subscribe thread alerts  
Subject:Access this type of OAuth 1.0a api?...
Summary:Need help configure this php client to work w/ the following API
Messages:7
Author:Jaisonb
Date:2015-02-11 15:56:11
 

  1. Access this type of OAuth 1.0a api?...   Reply   Report abuse  
Picture of Jaisonb 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.

  2. Re: Access this type of OAuth 1.0a api?...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-02-11 16:37:10 - In reply to message 1 from Jaisonb
Currently the class does not support X_AUTH.

I can try adding support to X_AUTH but I would need to have access to at least one server so I can try and see if it works.

If you know a server that supports X_AUTH that I can use, just let me know.

  3. Re: Access this type of OAuth 1.0a api?...   Reply   Report abuse  
Picture of Jaisonb Jaisonb - 2015-02-11 18:34:39 - In reply to message 2 from Manuel Lemos
Thanks for the reply! I've seen xauth used on twitter before.

Actually, here is twitter's documentation on using xauth, maybe this could help you work it into the library.

dev.twitter.com/oauth/xauth

  4. Re: Access this type of OAuth 1.0a api?...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-02-13 22:01:55 - In reply to message 3 from Jaisonb
Twitter requires a special authorization to allow xAuth support. I applied to enable it for an application that I created. Lets see if they approve it.

  5. Re: Access this type of OAuth 1.0a api?...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-02-14 00:06:34 - In reply to message 3 from Jaisonb
I got a reply from Twitter, they say that they do not enable xAuth support for development purposes. So I am afraid I cannot use Twitter to test any xAuth development support.

Couldn't you use the Resource Owner Password Credentials authorization flow explained in this article in the Authorization with the User Password section?

  6. Re: Access this type of OAuth 1.0a api?...   Reply   Report abuse  
Picture of Jaisonb Jaisonb - 2015-03-09 23:40:18 - In reply to message 5 from Manuel Lemos
Manual,

Thanks for the replys, I have found an API that looks pretty easy to get started with and has xauth support. Could you implement this into the oauth client ?

instapaper.com/api


  7. Re: Access this type of OAuth 1.0a api?...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2015-03-10 02:17:22 - In reply to message 6 from Jaisonb
OK, I requested access to use that API. Lets see if they approve it soon.