61378

How to create signature for twitter in Salesforce and what are the steps for signature creation

Question:

I need a signature for my first request to twitter :

My code create a Post request for this end Url <a href="https://api.twitter.com/oauth/request_token" rel="nofollow">https://api.twitter.com/oauth/request_token</a> and I have to set a header which is mention below in which I need signature.

I have only call back Url, consumer_key. I have created nonce and timestamp. I need signature.

Authorization Header: OAuth oauth_nonce="XXXXXXXXX", oauth_callback="XXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="XXXXXX", oauth_consumer_key="XXXXXX", oauth_signature="HOW I CREATE THIS", oauth_version="1.0"

Answer1:

I think twitter has a nicely written document on creating a signature. <a href="https://dev.twitter.com/docs/auth/creating-signature" rel="nofollow">https://dev.twitter.com/docs/auth/creating-signature</a>

Check it out...

Edit: I noticed your oauth_* parameters are not in order. Don't forget to get them in order.

Answer2:

You can use oauth module <a href="https://github.com/ciaranj/node-oauth" rel="nofollow">https://github.com/ciaranj/node-oauth</a>

var oauth=require('oauth'); var consumer = new oauth.OAuth( "https://twitter.com/oauth/request_token", "https://twitter.com/oauth/access_token", _twitterConsumerKey, _twitterConsumerSecret, "1.0A", "http://127.0.0.1:8080/sessions/callback", "HMAC-SHA1");

then generating signature like this :

var parameters = consumer._prepareParameters("user_access_token", "user_access_token_secret", "http_method", "request_url"); var headers = consumer._buildAuthorizationHeaders(parameters);

parameters array contains signature, also you can build authorization headers if needed. Hope it helps :)

Recommend

  • freeTDS on Linux and Azure database, login issue
  • Handling onclick for button added to another application
  • Magento - Custom subject of order email
  • How to Use Captcha Plugin in CodeIgniter
  • rails app not finding fontawesome icons on heroku
  • Smfony2 : HWIOauthBundle : Using multiple locales
  • Getting resultset from insert statement
  • OAuth - Error on Twitter (could not authenticate)
  • Firebase Datasnapshot for getChildrenCount sets to zero
  • Get Facebook Page Likes all at once in c#
  • Converting a doc to a pdf in a mvc c# environment
  • Related Videos with part contentDetails and Statistics - Youtube API V3
  • Using non-default service account in Google Cloud dataproc
  • Android Google maps co-ordinates
  • Redis - Using CONFIG SET on the fly in a master slave relationship
  • jQuery .css() method not working
  • Tibco error: ClassNotFoundException: com.tibco.tibjms.naming.TibjmsInitialContextFactory
  • Simple way to post a Twitter status update with VBScript or Perl
  • Chrome native messaging: can I stream a MediaStream to a native program?
  • Badly corrupted git repository
  • Accessing Flurry User ID
  • Twitter authentication with Javascript
  • Get key hash for release
  • Why do I get incorrect values when implementing HMAC-SHA256?
  • imported a certificate.pfx into cacerts and still getting “PKIX…unable to find valid certification p
  • Limiting unserialize() to return arrays?
  • Heroku not using the specified Ruby 1.9.3
  • Unable to save a query as a view table
  • Use double quote then curly brace in powershell -Command
  • Active Directory Powershell - forest-wide search script using .csv list of users
  • PHP exec response as string?
  • How to include Web reference endpoint configuration in another project
  • OAuth2 flow for mobile app
  • php notice undefined index http_host in $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'
  • Implementing HMAC-SHA256 for Keybase in Javascript
  • OAuth and the YouTube API
  • How to view images from protected folder with php?
  • Textfile Structure (tables)
  • vba code to select only visible cells in specific column except heading
  • Circular dependency while pushing http interceptor