Using oauth with a pre-obtained access token

64 views
Skip to first unread message

adam klein

unread,
Sep 11, 2011, 4:21:38 AM9/11/11
to OAuth Ruby
Hi
I'm using omniauth with google openid hybrid solution on my
application, and I'm able to retrieve the final access token + secret
for the user.
I've tried to sign the requests to google myself, but I was
unsuccessful (received a 403, "modification only allowed with api
authentication")
So I tried to use oauth, but I received the same error.
(In both ways, getting public data was successful, but posting new
data returned the error)

On the google oauth playground I've successfuly posted the data

Am I using oauth well? Here is what my code looks like:

@consumer = OAuth::Consumer.new('www.bl...', 'IGl...', :site =>
'www.bl...')

uri = URI.parse(base_url)
https = https_for(uri)
request = Net::HTTP::POST.new(uri.request_uri)

request["Content-Type"] = "application/atom+xml"
request.body = "<entry xmlns='http://www.w3.org/2005/
Atom' "+
" xmlns:media='http://search.yahoo.com/
mrss/' "+
.........

oauth_params = {:consumer => @consumer, :token => access_token}
oauth_helper = OAuth::Client::Helper.new(request,
oauth_params.merge(:request_uri => uri))
request.headers.merge!({"Authorization" => oauth_helper.header})

response = https.request(request)

thanks,
Adam Klein
Reply all
Reply to author
Forward
Message has been deleted
0 new messages