Bad Authentication data for /1.1/friendships/create


#1

I’m trying to create a follow button through the REST API but I always get a 215 error.
I’m using Scott Desapio’s classic ASP oauth library:

Const TWITTER_OAUTH_URL_ACCESS = "https://api.twitter.com/oauth/access_token"
Const TWITTER_OAUTH_URL_AUTHENTICATE = "https://api.twitter.com/oauth/authenticate"
Const TWITTER_OAUTH_URL_REQUEST_TOKEN = "https://api.twitter.com/oauth/request_token"
Const TWITTER_OAUTH_URL_UPDATE_STATUS = "https://api.twitter.com/1.1/statuses/update.json"
Const TWITTER_OAUTH_URL_FRIENDSHIP_CREATE = "https://api.twitter.com/1.1/friendships/create.json"
Const TWITTER_OAUTH_URL_FRIENDSHIP_LOOKUP = "https://api.twitter.com/1.1/friendships/lookup.json"
Const TWITTER_SCREEN_NAME = "screen_name"
Const TWITTER_SITE_SCREEN_NAME = "" 'screen name to follow'

objOAuth.ConsumerKey = OAUTH_EXAMPLE_CONSUMER_KEY
objOAuth.ConsumerSecret = OAUTH_EXAMPLE_CONSUMER_SECRET
objOAuth.EndPoint = TWITTER_OAUTH_URL_FRIENDSHIP_CREATE
objOAuth.Parameters.Add "screen_name", TWITTER_SITE_SCREEN_NAME
objOAuth.RequestMethod = OAUTH_REQUEST_METHOD_POST
objOAuth.Send()

I can create statuses no problem but when I try to follow I always get

{"errors":[{"message":"Bad Authentication data","code":215}]}

Also if i switch it back to API v1 it says:

{"request":"\/1\/friendships\/create.json?oauth_consumer_key=<key_here>&oauth_nonce=1431885555&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1352930155&oauth_version=1.0&screen_name=<account_here>&oauth_signature=<signature_here>","error":"Could not authenticate you."}

I have tried searching google endlessly and I have not found anything that seems to help. Thanks in advance!

Edit:
Seems to be doing it for everything in /friendships


#2

It doesn’t appear like you’re sending an oauth_token parameter to indicate the access token being used and the user who is doing the following.


#3

Thanks for your help. There must be two users in the request? So it would be &screen_name=user1,user2?


#4

Well, there needs to be an oauth_token in your actual OAuth that represents the current user. It’s the current user who is taking an application through your application, not your application taking an action itself…

This method only takes a single screen_name as its argument though – the second user, the one doing the following, is implied through the OAuth access token.


#5

Brian – did you solve this? You just need to use OAuth as per the documentation. Feel free to use my ASPTwitter class as a starting point. The code already does OAuth authentication and gets tweets, and works with Twitter API 1.1. Just copy the token method and change the API URL and post data:

http://www.timacheson.com/Blog/2013/jun/asptwitter


#6

See my reply below :slight_smile: