Posting to tumblr using API v2 on iOS returning error - ios

I recently got oAuth working for my iOS app to log in to Tumblr. Now I'm having trouble posting using the new API calls. I'm able to generate a request and prepare Autorization headers but I'm still getting errors.
Here is my URL:
http://api.tumblr.com/v2/blog/my_blog.tumblr.com/post?tweet=no&tags=my%2C%20app&state=published&type=text&title=Hello&body=I%2520finally%2520got%2520this%2520to%2520work
Here is my Authorization header with x's in place of sensitive info:
Authorization = "OAuth realm=\"\", oauth_consumer_key=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", oauth_token=\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\", oauth_signature_method=\"HMAC-SHA1\", oauth_signature=\"XXXXXXXXXXXXXXXXXXXXXXXXX\", oauth_timestamp=\"1347656207\", oauth_nonce=\"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\", oauth_version=\"1.0\"";
There error I receive:
{"meta":{"status":400,"msg":"Bad Request"},"response":{"errors":["Post cannot be empty."]}}
Does anyone have experience with this? I've been working at it for at least 20 hours over a two day period.
Any help is greatly appreciated.
EDIT: I've also tried including authorization data in the url (i.e., oauth_token, oauth_consumer_key), essentially the stuff found in the header. When I do this I get a 401 "Not Authorized" error, which I know isn't correct because I just successfully called "http://api.tumblr.com/v2/user/info" which requires a valid authorization.
found solution, see explanation here.

Related

youtube-api on JavaScript backend

After 2 weeks that I was using that API correctly and I have upload a few video on YouTube, today I receive this error when I try to get a new access token:
Error 400: invalid_scope
Some requested scopes were invalid. {invalid=[https://googleapis.com/auth/youtube.upload]}
Also with the old access token that was working yesterday, now I cannot proceed..
Now I can think that YouTube for some reason have blocked me or something like that because I haven't changed the code.. Anyone have experienced something like this? How I can proceed? At least I want to know if I was 'blocked' and for what reason.

YouTube Analytics API : 403 Forbidden Error returns Earnings Report

I have a CMS account an I'm trying to get earnings data from content owners report on Analytics API using OAuth 2.0 . Whenever I'm trying to do this through my website, I get the following error ;
Error calling GET https://www.googleapis.com/youtube/analytics/v1/reports?ids=contentOwner%3D%3DContentOwnerID&start-date=2005-01-01&end-date=2015-11-26&metrics=views%2Cearnings%2Clikes%2Cdislikes%2Cshares%2Ccomments&dimensions=30DayTotals&filters=channel%3D%3DChannel_ID: (403) Forbidden
I'm doing the same thing on TRY IT page and it works fine.
I'm thinking that I'm having issues with authenticating my domain. What do you think is the problem? How can I solve this issue?
Thank you,
403 means nobody has access to a page. As you noticed, you may have access to a similar page, but not to this one. It is not a matter of authentication. Authentication problems give a status 401 (meaning it can be fixed by adding proper authentication); 403 cannot be fixed.
Finally, I solved the problem..
Whoever will have this issue, please use the CMS user's OAuth 2.0 credentials instead of using channel credentials..

How to fix 401 Unauthorized with Twitter oAuth

Hopefully someone here can help me fix this. I have been trying to make a web app for twitter, I have setup my application in the developer section of the twitter website.
I have set a callback url in both the developer section and in my code.
Where I get stuck is I get a 401 Unauthorized exception when requesting the Access Token. The app correctly sends the user to Twitter to ask for authorization, and then twitter send back to my callback URL successfully. My webapp then tries to request the access token and thats when the exceptions happens.
Below is an example of the API I call:
https://api.twitter.com/oauth/access_token?oauth_callback=http://www.example.com&oauth_consumer_key=6Rfhub7fDgCIazdg4dMECT6fJ&oauth_nonce=1721260&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1403965501&oauth_token=RCbfmuvzqFjJWHwCtWfNqEQ22uXFvv422AtHfBBYE&oauth_verifier=0QuTFy5SBmAl29VIWkBjfogJQ7GiSAoR2qIjokoii0&oauth_version=1.0&oauth_signature=JRzlH5Fiv5Ani3P+oXj5dxV58cA=
Any ideas where I might be going wrong?
Thanks
EDIT: Im using code from here http://www.aspdotnet-suresh.com/2012/05/add-twitter-login-authentication-to.html
and I changed it to use https:// not http://
Couldn't fix this issue. Using TweetSharp instead.

Twitter API issues.“Authentication needed”"Failed to validate oauth signature and token"

Friends,I got a question,and I have googled it,but I didn't find the answer.
I create an iOS twitter app,and apply for a twitter API.
I used my API key in my app,Xcode returns error.
Just like this: http://tinypic.com/r/262ksnk/8
("Failed to validate oauth signature and token")
and this picture is my twitter api status
(sorry,I do not have enough coin to upload a pic,so post my pic here. )
what is wrong with my twitter api,can anyone help me?
Thanks very much.
What is wrong?
Best regards.
This error message relates to a HTTP 401 response.
Please make sure you are properly signing your OAuth requests. This guide will help you with the common pitfalls: Troubleshooting OAuth 1.0A.
In particular, if you are using valid keys and properly signing your OAuth requests but still receiving 401 errors, please check your system time. Since the OAuth signature relies on the current time, it must be in sync with the one from Twitter servers (exposed in all Date response headers from the Twitter API).
The "performance issues" described on the Twitter API status page apply to Twitter as a whole, and have nothing to do with your application. If you are having issues interacting with the Twitter API, we cannot diagnose those from the information provided ("error 3").

Keep getting OAuth::Unauthorized error when using oauth and twitter ruby gems

I am using the ruby twitter gem and oauth to gain access to users twitter accounts. In my code, I have:
unless #user.twitter_authd?
oauth = Twitter::OAuth.new('token', 'secret')
session[:twitter_request_token] = oauth.request_token.token
session[:twitter_request_secret] = oauth.request_token.secret
#twitter_auth_url = oauth.request_token.authorize_url
end
where token and secret have my actual token and secret inserted. When I click on the link to the #twitter_auth_url, I am taken to twitter and asked to grant access. I click allow and then twitter redirects me to my callback URL http://www.mydomain.com/twitter_callback/?oauth_token=fmy2aMvnjVgaFrz37bJ4JuB8r5xN79gsgDQRG4BNY which then hits this code:
oauth = Twitter::OAuth.new('token', 'secret')
logger.info("session[:twitter_request_token] = #{session[:twitter_request_token]}")
logger.info("session[:twitter_request_secret] = #{session[:twitter_request_secret]}")
oauth.authorize_from_request(session[:twitter_request_token], session[:twitter_request_secret])
session[:twitter_request_token] = nil
session[:twitter_request_secret] = nil
#user.update_attributes({
:twitter_token => oauth.access_token.token,
:twitter_secret => oauth.access_token.secret,
})
redirect_to root_path
The twitter request token and secret are being set just fine. However I end up with an authorization error:
OAuth::Unauthorized in MainController#twitter_callback
401 Unauthorized
RAILS_ROOT: /Users/TAmoyal/Desktop/RoR_Projects/mls
Application Trace | Framework Trace | Full Trace
/Library/Ruby/Gems/1.8/gems/oauth-0.3.4/lib/oauth/consumer.rb:167:in `token_request'
/Library/Ruby/Gems/1.8/gems/oauth-0.3.4/lib/oauth/tokens/request_token.rb:14:in `get_access_token'
/Library/Ruby/Gems/1.8/gems/erwaller-twitter-0.6.13.1/lib/twitter/oauth.rb:29:in `authorize_from_request'
/Users/TAmoyal/Desktop/RoR_Projects/mls/app/controllers/main_controller.rb:70:in `twitter_callback'
The code is failing at this line:
oauth.authorize_from_request(session[:twitter_request_token], session[:twitter_request_secret])
when it tries to get an access token. You can see the source code of authorize_from_request here. I am not sure why this is happening. Anyone have ideas?
A bit late to the party but just ran into the same issue myself. I tracked the issue down to the setup of my OAuth app in Twitter. I had initially not specified a callback URL as I was unsure of it.
Once I had setup my rails app I went back to find Twitter had assumed I was a desktop application as I hadn't specified a callback URL. Once I changed this to website and entered a callback URL I stopped getting 400s.
If you're getting error 401 - OAuth::Unauthorized, make sure you edit the settings of your Twitter application as follows:
Application Type: Browser
Callback URL: http://127.0.0.1:3000/auth/twitter/callback
this is an issue about time synchronization of your system with twitter server.
Twitter doesn't allow localhost as part of a valid callback URL.
Instead use http://127.0.0.1:3000/auth/twitter/callback
Hope this helps
This was one of the most annoying things to debug that I have come across. I was outputting in a couple places by accident because the URL's are dynamic and they happened to not be defined in my test case (i use this to display chart data and there is not enough right now so the google chart api URL's are blank). This caused my browser to make multiple requests to my localhost when some pages were loaded. Somehow that made the oauth process crap out. Obviously there is no way for people on S.O. to know about my application specific issue so I had to answer my own question.
I had this same problem and none of the suggestions in this thread worked for me.
I found the problem for me was the TIMESTAMP on my request. The mobile device I was running my scripts on had a jacked up clock. When I updated the system time on my device to the correct time (i.e. now), all of my requests came back "200 OK" instead of "401 Unauthorized".
This problem seems to be caused by twitter not being able to handle connection keep-alive correctly. Make sure you set connection=close http header in the request to twitter. Wasted a weekend debugging this.
not enough info for me, but when was twitter gem last updated? twitter changed their oauth 'stuff' in mid may approx. perhaps you have an old one. I'd update your question to show the callback_url, and make sure you have the right token and secret, which it looks like you don't have.
also, did you put the right callback url in your twitter app page? alot of times that screws you up too.
if that fails use mbleighs twitter_auth instead. it worked for me and is pretty slick.

Resources