themattharris / tmhOAuth

An OAuth 1.0A library written in PHP
Apache License 2.0
855 stars 335 forks source link

Auth problems #183

Open FooleanBool opened 9 years ago

FooleanBool commented 9 years ago

Hi Matt. First off thanks for sharing this OAuth implementation and secondly thanks for replying to my twitter message. I have installed and configured your web examples with my twitter app keys. When running the 'verify credentials' part, I get a successful response and the latest tweet is shown. When running the 'auth flow; part, I also get a successful response and am invited to authorise the app with a twitter based authorise button, and am successfully redirected back to the calling page. However, when trying to search for any keyword: HTTP/1.1 400 Bad Request {"errors":[{"code":215,"message":"Bad Authentication data."}]}


When I try to use the photo_tweet part I receive:
HTTP/1.1 100 Continue HTTP/1.1 403 Forbidden {"errors":[{"code":189,"message":"Error creating status."}]} My app is set to read/write permissions, and when using the twitter OAuth signing results curl command form my terminal (GET /1.1/search/tweets.json?q=egg HTTP/1.1) I do get a valid response. The only thing missing from the config array is the 'bearer' which is left blank (''), simply because I have no idea what to put there. I get the same behaviour running from localhost dev machine and from my online web host. Have you any idea what I have missed? I apologise if I am being an idiot and doing something wrong, but I've read through the instructions more than once and can't find anything amiss. I appreciate your help with this, Paul.

eXorus commented 9 years ago

Same for me it was working well a few months ago.

themattharris commented 9 years ago

hey guys, bad authentication data comes back from twitter when the oauth token or secret are missing or invalid. can you update your scripts to output $this->config['user_token'] and $this->config['user_secret'] - just to make sure they are there.

user_requests (those that use the results of the auth flow and user_token and user_secret should be invoked with $tmhOAuth->user_request.

the bearer that you are referring to is for application only auth (https://dev.twitter.com/oauth/application-only) and is invoked using $tmhOAuth->apponly_request. a blank bearer here will cause bad authentication data.

for the 403 you are getting when creating a status. there are many reasons for a 403 to come back from twitter. inspect the contents of $tmhOAuth->response['response'] to see the error message twitter responded with.

eXorus commented 9 years ago

I have the error message : [code] => 403 [response] => {"errors":[{"code":189,"message":"Error creating status."}

when I post to https://api.twitter.com/1.1/statuses/update_with_media.json

I used consumer_key, consumer_secret, token and secret The bearer is empty but the user_token and secret are used.

I never used $tmhOAuth->apponly_request and it was working before so ...