The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Stumbling on OAuth

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Stumbling on OAuth Posted: Nov 3, 2009 10:42 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Stumbling on OAuth
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

I'm trying to work with the OAuth interface to Twitter - I haven't gotten very far, as I get a 401 on every attempt to request a token. Here's the workspace code I've been experimenting with:


url := 'http://twitter.com/oauth/request_token'.
nonce := Timestamp now asMicroseconds asByteArray asHexString.
parms := Dictionary new.
parms at: 'oauth_consumer_key' put:  twitConsumerKey.
parms at: 'oauth_version' put: '1.0'.
parms at: 'oauth_timestamp' put: Timestamp now asUnixSeconds printString.
parms at: 'oauth_signature_method' put: 'HMAC-SHA1'.
parms at: 'oauth_nonce' put: nonce.
keys := parms keys asSortedCollection.
text := twitTokenReqUrl.
encoded := OS.URI encode: text.
stream := WriteStream on: String new.
stream nextPutAll: 'GET&', encoded.
keys do: [:key |
	stream nextPutAll: '&', key, '=',  (parms at: key)].
sigBase := stream contents.
okey := twitConsumerSecret, '&'.
sig := ((HMAC SHA: okey asByteArray) hash: sigBase) asBase64String.


keys add: 'oauth_signature'.
parms at: 'oauth_signature' put: sig.
client := HttpClient new.
request := client requestClass method: 'GET' url: url.
request contentType: 'application/x-www-form-urlencoded'.
keys do: [:each |
	request addFormKey: each value: (parms at: each)].

client executeRequest: request.

Anyone see anything obviously wrong in that? I'm looking at the Twitter API pages and the OAuth spec pages...

Technorati Tags: ,

Read: Stumbling on OAuth

Topic: Cut the Cable Previous Topic   Next Topic Topic: Smalltalk Daily 11/02/09: Installing VW on Windows

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use