Goodreads Developers discussion

136 views
questions > XMLHttpRequest cannot load when trying to load request_token.authorize_url

Comments Showing 1-2 of 2 (2 new)    post a comment »
dateUp arrow    newest »

message 1: by K.manji (new)

K.manji (Kmanji) | 1 comments The redirect_to request_token.authorize_url (called from my controller) gives an error:
XMLHttpRequest cannot load http://www.goodreads.com/oauth/author.... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://0.0.0.0:3000' is therefore not allowed access.

in my controller, this def is called by $.ajax after button click:
request_token = OAuth::Consumer.new(
Goodreads.configuration[:api_key],
Goodreads.configuration[:api_secret],
:site => 'http://www.goodreads.com'
).get_request_token

redirect_to request_token.authorize_url

This is my ajax:
$.ajax(
url: "/my/readings/goodreads_oauth"
type: 'POST'
dataType: 'jsonp'
data:
title: $title
author: $author
review: $review
rating: $rating
success: (data) ->

if i put the request_token.authorize_url directly into my browser the page opens correctly. But won't work through redirect_to. Why won't the page open?


message 2: by Michael (new)

Michael Economy (michaeleconomy) I think your browser will block this request because it think's it's a XSS attack.

It's rather difficult to implement oauth in front end javascript code because of this.


back to top