I am trying to connect with twitter from slaesforce, but it's not allowing me to connect. Alwys throwing error "Basic Authentication is not supported"? So what I need to do now?


#1

Hi,

I am trying to connect with twitter from Salesforce.com.

Http h = new Http();
HttpRequest req = new HttpRequest();
req.setMethod(‘POST’);
req.setEndpoint(‘https://api.twitter.com/1/statuses/update.xml’);
req.setHeader(‘Content-Type’,‘application/x-www-form-urlencoded’);
Blob headerValue = Blob.valueOf(‘username:password’);
String authorizationHeader = 'Basic ’ + EncodingUtil.base64Encode(headerValue);
req.setHeader(‘Authorization’, authorizationHeader);

but it throws error to me that basic authentication is not allowed. Please help me to transform it in OAuth request. I don’t know how to do that in salesforce.

Regards


#2

Basic auth hasn’t been supported on the API for quite a long time now. You’ll find OAuth difficult but not impossible in SalesForce – [node:139] explains the basics on a high level but you’ll need to do some research to find the right libraries and tools for SalesForce.


#3

Request Token URL https://api.twitter.com/oauth/request_token
Access Token URL https://api.twitter.com/oauth/access_token
Consumer Key someKsy
Consumer Secret soemSecret
Authorization URL https://api.twitter.com/oauth/authorize

I have setup all these values, now when I try to authorize it it throw error to me:
Problem: Failed getting a request token. HTTP Code = 401. Message: Unauthorized. Response Body: <?xml version="1.0" encoding="UTF-8"?> Desktop applications only support the oauth_callback value ‘oob’ /oauth/request_token

Please help me to resolve this.


#4

Any help?


#5

If you’re going to use an oauth_callback approach and send an explicit URI-based oauth_callback value on the oauth/request_token step, you’ll need to set your application in a mode that accepts these dynamic callbacks. You can do this by setting your placeholder callback URL on your application record to a valid non-twitter.com URL like “http://salesforce.com/my_app