what happens if i dont knw the user id before hand, i know it only after
authorisation??
For more information:
http://code.google.com/p/oauth-php/wiki/ConsumerHowTo
@satyadeep.1991:
I believe the userid is meant to be from your own application/system, and
not one from a service.
How can I change the database driver to MySQLi? Thanks in advance!
Hello, at r130, some tests are failing for me.
$ php oauth_test.php
...
Assertion failed in
/Users/simonreekie/Tmp/oauth-php-130/test/oauth_test.php:90
$req->getNormalizedParams() == 'a=x%20y&b=x%21y'
...
Assertion failed in
/Users/simonreekie/Tmp/oauth-php-130/test/oauth_test.php:106
$req->signatureBaseString()
== 'POST&https%3A%2F%2Fphotos.example.net%2Frequest_token&oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dhsu94j3884jdopsl%26oauth_signature_method%3DPLAINTEXT%26oauth_timestamp%3D1191242090%26oauth_version%3D1.0'
Anyone else seeing this? This doesn't happen in r98 which I am using
successfully at the moment - but I'd really like to use the version that
supports 1.0a...
@simon.reekie
Can you file an issue for this in the issues section? I think it will get
lost in this wiki... ;o)
@simon.reekie
You have to instanciate the Store with MySQLi parameter:
$store = OAuthStore::instance('MySQLi', $options);
ups... i did mean @cezar.elnazli in my last comment! Sry simon! ;o)
Np Andre :-) I've filed an issue for the failing tests.
Cross-posted from ServerHowTo, apologies...
--
Hi, I'm trying to get twolegged OAuth to work against my OAuth server. My
first confusion is that in twoleggedtest.php, the url being accessed is
the 'request_token' endpoint:
$key = 'key'; // fill with your public key
$secret = 'secret'; // fill with your secret key
$url = "http://term.ie/oauth/example/request_token.php"; // fill with the
url for the oauth service
Is that correct? Can it not be set directly to
a '$server->verifyIfSigned()' wrapped page on my server?
So when I do change the url in the example to go directly to my page I can
only get that page to work if I call '$server->verifyIfSigned(false)', ie.
a token_type of false.
In this way i'm not able to call the same page in both normal three legged
and two legged!?
Has anyone got this to work? I am quite certain I might be just not
understanding the twolegged use correctly of course :-)
Thanks.
Hello everyone.
How use xoauth_requestor_id in this library for 2-legged OAuth?
I want to access to
http://www.google.com/calendar/feeds/default/private/full. It is a google
apps calendar, and i must use 2-legged OAuth.
Help me, please!
Hi - I'm attempting to use oauth-php with Googles OAuth API. However, when
it comes to requesting an access token I'm finding the two legged approach
is encoding the token twice, causing malformed tokens and resulting in them
being rejected by Google.
The problem comes here:
$params = array(
'oauth_token' => OAuthRequest::urldecode($_GET['oauth_token']),
'oauth_verifier'=> OAuthRequest::urldecode($_GET['oauth_verifier'])
);
$oauth = new OAuthRequester(ACCESS_URI, 'GET', $params);
When the token is passed into the OAuthRequester constructor, it is passed
to the OAuthRequestSigner constructor, which then sets the parameters and
encodes them.
The problem comes to when the request gets signed on line 131 of
OAuthRequestSigner.php:
$this->setParam('oauth_token', $token);
The token is again set as a parameter causing any encoded characters
(encoded by the constructor) to be re-encoded causing malformed tokens.
Before OAuth i Googled "post to twitter using PHP". The first hit gave me
a few lines of code. I copied its 5 or 6 lines, populated $username,
$password, and $message. I ran it. It posted.
This crap here? I have no idea what it's even talking about.
Can anyone point me to 5 or 6 lines of code I can paste to make PHP post to
Twitter now?
I really like this library vs. other ones I have found since it has a great
mechanism for storing OAuth credentials. Has anyone out there made a patch
to bring support up to OAuth 1.0a or does anyone know what the status of
this planned support is? Good job on the library in any case.
Hello,
Thanks for confirming that OAuth 1.0a is already supported. I am trying to
get it implemented in my client but have the following questions:
Referring to this:
http://mojodna.net/2009/05/20/an-idiots-guide-to-oauth-10a.html
1. I am passing oauth_callback as an parameter when I request a request
token.
2. However, I don't get oauth_callback_confirmed=true when the server
responds with a request token. Also, I don't get an oauth_verifier
returned. So how do I request an access token without the oauth_verifier?
The only thing that is returned in the request token are the authorization
uri and the request token itself.
Apologies in advance if I am missing something really obvious.
There is no curl here. How do I use the script for twitter?
Warning: Only the server has been updated to 1.0a, the client is still 1.0
and thus does not have working callbacks (the example alone demonstrates
this, as you cannot pass the callback via url parameters anymore, it's part
of the RequestToken phase).
The examples/documentation here is completely wrong for 1.0a use, and I was
convinced the library was incompatible for a long time before I figured out
how it wanted things passed around.
For OAuth 1.0a, you DO NOT pass the callback via url as the current example
shows, but via curl while getting the request token. So in step 3 your call
will become
`$token = OAuthRequester::requestRequestToken($consumer_key, $user_id,
array('oauth_callback' => $callback_uri));`
You must then get the oauth_verifier and include it in the access token
request, like so:
`OAuthRequester::requestAccessToken($consumer_key, $oauth_token,
$user_id, 'POST', $_GET['oauth_verifier']);`
Hope that saves some people the ridiculous amount of time it took me to
realize this.
I keep throwing:
CURL error: SSL certificate problem, verify that the CA cert is OK.
Details: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Although, when I visit the API url in chrome, it claims the certificate is
valid (signed by VeriSign), where should I begin to look for issues?
*oauth-php-super-easy-example.zip*
After spending 3 days testing different libs to get oauth to connect to
Twitter, I setup a (hopefully) very easy example based on andy smith's
implementation (http://oauth.googlecode.com/svn/code/php/). I hope that
this will save others a lot of hours of work to just see it in action.
My goal was to setup a complete example that would *just work* without a
lot of fuss.
It uses CURL to process all outbound calls to Twitter, so make sure your OS
has it installed. Tested with php v5.3.3. Make sure you open up both
client.php and common.inc.php and change the include paths as needed.
*oauth-php-super-easy-example.zip*
https://docs.google.com/leaf?id=0B0FXNCj3-C0AYjgwYWQzY2YtN2VjYi00N2Y1LWJkNjQtM2I0ODBiZDU3MTI5&hl=en
oauth-php-super-easy-example.zip
After spending 3 days testing different libs to get oauth to connect to
Twitter, I setup a (hopefully) very easy example based on andy smith's
implementation (http://oauth.googlecode.com/svn/code/php/). I hope that
this will save others a lot of hours of work to just see it in action.
My goal was to setup a complete example that would *just work* without a
lot of fuss.
It uses CURL to process all outbound calls to Twitter, so make sure your OS
has it installed. Tested with php v5.3.3. Make sure you open up both
client.php and common.inc.php and change the include paths as needed.
get it here:
Hi Arievanderberg,
I believe your script is for web client, do you have one for pin-based
server client?
Thanks
@ arievandenberg : i am getting following error in you clinet.php code
"SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify
failed"
when i print curl_error for "request_token" action..
Also, im getting same error for oauth-php\example\twoleggedtwitter.php
I m running code from my localhost but i have made host entry for the
callback domain(of callback url) that i have registered with Twitter and
passing same consumer key and consumer secret that twitter gave me upon
registration of app.
Am i doing something wrong over here..why is this error..??
please help
Ok i have resolved that issue.related curl and ssl thingy
Is there any way to do the 3-legged without setting up a MySQL database and
just using some temp memory for the store?
Hi.
I'm using the library oauth-php for use this API:
http://developer.trademe.co.nz/
I have connected, also got the access token and got information through API.
But now I need to send information to API, I need to send a XML String for
web request.
With oauth-php I can do it?
Can I use OAuthRequester method to send the XML via web request?
Somebody can show me an example how I can send XML with OAuthRequester?
XML:
<code><ListingAnswerQuestion xmlns="http://api.trademe.co.nz/v1">
<answer>Yes it does blend.</answer>
</ListingAnswerQuestion>
</code>
Link Method:
http://developer.trademe.co.nz/api-documentation/listing-methods/answer-question/
Kind regards.
Hemerson.
Hello :)
I implemented the same code as given in the example, however im getting
this error after the first register goes fine, the second time I run the
code it gives this:
Fatal error: Uncaught exception 'OAuthException2' with message 'The server
with key "students.lgu.edu.lb" has already been registered' in
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/store/OAuthStoreSQL.php:782
Stack trace: #0
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/index.php(19):
OAuthStoreSQL->updateServer(Array, '1') #1 {main} thrown in
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/store/OAuthStoreSQL.php
on line 782
If I run the code the first time I get a different error, which is this:
OAuthException: No server with consumer_key "students.lgu.edu.lb" has been
registered (for this user)object(OAuthException2)#2 (7) {
["message":protected]=> string(85) "No server with
consumer_key "students.lgu.edu.lb" has been registered (for this user)"
["string":"Exception":private]=> string(0) "" ["code":protected]=> int(0)
["file":protected]=>
string(85) "/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/store/OAuthStoreSQL.php"
["line":protected]=> int(453) ["trace":"Exception":private]=> array(2) {
[0]=> array(6) { ["file"]=>
string(80) "/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/OAuthRequester.php"
["line"]=> int(155) ["function"]=> string(9) "getServer" ["class"]=>
string(13) "OAuthStoreSQL" ["type"]=> string(2) "->" ["args"]=> array(2) {
[0]=> string(19) "students.lgu.edu.lb" [1]=> int(0) } } [1]=> array(6) {
["file"]=>
string(67) "/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/index.php"
["line"]=> int(25) ["function"]=> string(19) "requestRequestToken"
["class"]=> string(14) "OAuthRequester" ["type"]=> string(2) "::"
["args"]=> array(3) { [0]=> string(19) "students.lgu.edu.lb" [1]=> int(0)
[2]=> array(3) { ["scope"]=> string(29) "http://docs.google.com/feeds/"
["xoauth_displayname"]=> string(12) "LGU Students" ["oauth_callback"]=>
string(13) "ManageAccount" } } } } ["previous":"Exception":private]=> NULL }
I really need help in applying a MySQL storage rather than the Session one,
though I dont have problems in implementing the Session storage, works like
a charm.
I Appreciate the help
Hello :)
I implemented the same code as given in the example, however im getting
this error after the first register goes fine, the second time I run the
code it gives this:
Fatal error: Uncaught exception 'OAuthException2' with message 'Unexpected
result from the
server "https://www.google.com/accounts/OAuthGetRequestToken" (400) while
requesting a request token' in
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/OAuthRequester.php:169
Stack trace: #0
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/index.php(21):
OAuthRequester::requestRequestToken('students.lgu.ed...', '1') #1 {main}
thrown in
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/OAuthRequester.php
on line 169
I really need help in applying a MySQL storage rather than the Session one,
though I dont have problems in implementing the Session storage, works like
a charm.
I Appreciate the help
Hisham
So I managed to make it work, but after it registers the consumer key in
the db, i started to get this error, which doesn't go until I delete the
value from the database:
Fatal error: Uncaught exception 'OAuthException2' with message 'The server
with key "domain.com" has already been registered' in
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/store/OAuthStoreSQL.php:782
Stack trace: #0
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/index.php(19):
OAuthStoreSQL->updateServer(Array, '1') #1 {main} thrown in
/home/hisham-a/public_html/x/newsys/files/gmail/apigoogle/lib/store/OAuthStoreSQL.php
on line 782
how is it supposed to work ?
regards,
hisham
$consumer_key = $store->updateServer($server);
Hi. I have to get access for 2 or more APIs. I changed the googledocs.php
example file like;
$getAuthTokenParams = array('scope' =>
'http://docs.google.com/feeds/ http://www.google.com/calendar/feeds/
http://www.google.com/m8/feeds/',
'xoauth_displayname' => 'xxx',
'oauth_callback' => 'http://xxx/googledocs.php');
$request = new
OAuthRequester("http://docs.google.com/feeds/default/private/full/", 'GET',
$tokenResultParams);
The grant access page is working well I got the token. But when it returns
back to googledocs.php again, it gives me:
Request failed with code 400: Invalid request URIobject(OAuthException2)#4
(7) { ["message":protected]=> string(49) "Request failed with code 400:
Invalid request URI"
I also tried to fetch data with only one API access. There was no problem.
Can you please help me?
RE: You always need to initialize the OAuthStore before you can start using
the OAuth library.
Can someone provide an example of what needs to be done here? I have the
MySql database created and I'm looking for sample/example code to run as a
next step. Thanks
running oauth-example.php and getting 500 error which states "no server
with consumer key xxxx has been registered". Do I need to enter this info
outside the program? Or is some other function failing (no other errors
reported; sql logs are clean too.
I've encountered and gotten past a number of errors, but I'm stuck on this
one:
Fatal error: Uncaught exception 'OAuthException2' with message 'The server
with key xxxx has already been registered' in
C:\xampp\htdocs\oauth-php\library\store\OAuthStoreSQL.php:782 Stack trace:
#0 C:\xampp\htdocs\oauth-php\example\client\fitbitoauth.php(27):
OAuthStoreSQL->updateServer(Array, 1) #1 {main} thrown in
C:\xampp\htdocs\oauth-php\library\store\OAuthStoreSQL.php on line 782
Any suggestions anyone?
i could get it to work finally, took few hours. It might be a good idea to
refer to the sample program lying in the oauth-php that one can use to test
concepts.
Those who are trying it for the first time, please note that there are
nuances specific to versions of oauth and additional parameters required by
different service providers. Nevertheless, the library provides optional
arguments to deal with it.Refer to Comment by nmaste...@gmail.com, Nov 4,
2010 above for one such change. I have tried google, yahoo and here are key
diffferences that i could see till now:
Google:
a request token from the server. You would require optional argument to
provide scope parameter for google
$token = OAuthRequester::requestRequestToken($consumer_key, $user_id,
array('scope' => "https://www.google.com/m8/feeds/contacts/default/full/"));
Yahoo
$token = OAuthRequester::requestRequestToken($consumer_key, $user_id,
array('oauth_callback' => 'http://netucation.co.in/ef'));
I am exploring:
when server allows user to authenticate with google, how to get
this "userid" in case of multiple such users coming to my server. There
would be cases, who won't complete the authentication and leave it in
between. Example quoted here requires userid at the begining, when our
program does not know whether the user is a new one or an existing one or
whether he/she would complete authentication (ghost).
Have couple of threads, will update more when i conclude.
Hi, Would appreciate help on this one.
I am working in a situation where I have to use this oauth library, and the
access token is stored in custom table (it has to be like this) rather than
the default ones using OauthStoreMysql. I am using OauthStoreSession to get
the access token and save it to my database.
I am having problems doing the final part of oauth, getting user info. Is
there a way I can plug in the access tokens I already have into this code
and send it off to retrieve user info?
Im trying it on twitters api.twitter.com/1/account/verify_credentials.json
at the moment.
Basically I already have an access token stored in a string, and I want to
get user info!
Thanks in advance!
When using three legged oauth it is important that you do not include
oauth-php/library/OAuthRequester.php before you have stored the new server.
It would be nice if you also mentioned that you have to import
oauth-php/library/store/mysql/mysql.sql before creating the server.
Hi everyone,
I'm really new to this stuff and going through the process as best I can, I
feel like I have general grasp on things but I can't figure out Step 1. I'm
not sure if it's my database settings or what, but I basically copy what is
shown in the code snippet and replace everything with my data, but never
see the echo I have after it and get an Internal Server Error (500) on the
page. Can someone help me out or give me some things to check to try to get
this working?
Thanks in advance!
Hi,
To make signed requests having already stored the access token and secret,
you just need to do this:
$store = OAuthStore::instance('Session', $server); //server description
$store->addServerToken($CONSUMER_KEY, $token_type, $ACCESS_TOKEN,
$ACCESS_TOKEN_SECRET, $user, $options=array());
Hope this will be useful for somebody :)