Context

I'm trying to get an Access Token from the Flickr API using their their OAuth specification.

The first step to get an Access Token is to obtain a Request Token. I successfully manage to generate a correctly signed and valid URL to request this token: when I copy/paste the generated URL in my browser, I get the correct response.

Problem

As this part doesn't concern the user, I'm trying to get the Request Token by making a simple Ajax call:

console.log(baseURL + "?" + requestURL);
// When I copy/paste the log result in my browser, it works.

$.ajax({
    url: baseURL,
    type: 'GET',
    data: requestURL,
    done: function(data) {
        console.log('Request Token data', data);
    }
});

The problem is that I get an Access-Control-Allow-Origin issue:

XMLHttpRequest cannot load http://www.flickr.com/...
Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin. 

I've tried using dataType: 'jsonp' as a parameter of the Ajax call without any success:

GET http://www.flickr.com/... 401 (Unauthorized)

Any ideas? Thank you very much in advance for your help!

有帮助吗?

解决方案

It is not possible to implement Oauth 1.0 through just javascript without any server side script. Since the flickr's new authentication process is based on Oauth 1.0a. You got to use a server-side script.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top