Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS header? #8

Open
robinvanb opened this issue Dec 14, 2015 · 10 comments
Open

CORS header? #8

robinvanb opened this issue Dec 14, 2015 · 10 comments

Comments

@robinvanb
Copy link

I saw the other issue that was closed about the CORS header but I simply cannot seem to get this to work.
I'm using the consumer key / secret and the access token / access secret from the OAuth Tool of Twitter to configure $twitterApi but I keep getting the HTTP 400

Also there are many discussion topics about Twitter not supporting CORS: https://twittercommunity.com/t/access-control-allow-origin/7253/19
Do you have any idea what to do?

@saimon24
Copy link
Owner

If you get a 400 Error you are not logged in at all, which means you have no OAuth Token. Are you sure you get a valid token before you configure/use ngTwitter?

@k-zakhariy
Copy link

@saimon24 How i can get valid Token? When i complete auth i got access_token and access_token_secret , those are same credentials as in apps.twitter.com in Dashboard
Then when i try request i get the same error that @robinvanb had.

XMLHttpRequest cannot load https://api.twitter.com/1.1/statuses/home_timeline.json?count=5. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://local.regrem.com' is therefore not allowed access. The response had HTTP status code 400.

@botezalexandru
Copy link

I am also have the same issue, i copied the Consumer Key (API Key), Consumer Secret (API Secret) and the Access Token and it did not work

@sebastianmusial
Copy link

sebastianmusial commented Jul 22, 2016

@saimon24 I have the same problem. The response had HTTP status code 400.

Do we need token object with oauth_token and oauth_token_secret or third parameter must be oauth_token? In the both version this is not working.

@botezalexandru
Copy link

I did a little of debugging through the source code and oauth_token and oauth_token_secret were undefined so i initialized them like this:
clientId = 'xxxx'
clientSecret = 'xxxx'
token.oauth_token = 'xxxx'
token.oauth_token_secret = 'xxx'

then i would call: $twitterApi.configure(clientId, clientSecret, token);

now the oauth_token and oauth_token_secret are defined but it still shows me the same error

@sebastianmusial
Copy link

@botezalexandru I agree with you. Maybe javascript connection with Twitter without backend is not available - https://twittercommunity.com/t/access-control-allow-origin/7253/24 ? 😕

@liadlivnat
Copy link

@botezalexandru Hey, Did you figure it out eventually ?

@botezalexandru
Copy link

@liadlivnat no, i haven't

@msieurtoph
Copy link

msieurtoph commented Oct 8, 2016

@saimon24 : Your service just does not work ... I did the same thing as @botezalexandru (I went to same conclusion about token being an hash) and the preflight request does not contain any Authorization header as it should be (as far as I understand).

Using this :

twitter = {
        clientId: 'xxx',
        clientSecret: 'xxx',
        oauthToken: {
            'oauth_token': 'xxx',
            'oauth_token_secret': 'xxx'
        }
    };

$twitterApi.configure(twitter.clientId, twitter.clientSecret, twitter.oauthToken);
$twitterApi.getUserTimeline({count: 10}).then(function(){.....});

does not work ... I got the same error than @robinvanb.

@nadeemramsing
Copy link

Having the same issue:

OPTIONS https://api.twitter.com/1.1/statuses/home_timeline.json?count=5 400 ()

XMLHttpRequest cannot load https://api.twitter.com/1.1/statuses/home_timeline.json?count=5. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://nadeemlocalhost.mu:8080' is therefore not allowed access. The response had HTTP status code 400.

Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"https://api.twitter.com/1.1/statuses/home_timeline.json","params":{"count":5},"headers":{"Accept":"application/json, text/plain, */*","Authorization":"OAuth oauth_consumer_key=\"MYCONSUMERKEY\",oauth_nonce=\"cnM8AK8FhO\",oauth_signature_method=\"HMAC-SHA1\",oauth_token=\"undefined\",oauth_timestamp=\"1482916373\",oauth_version=\"1.0\",oauth_signature=\"AfGCImRpQRHncjHhGIZ8bBZxd6o%3D\""}},"statusText":""}

I noticed that oauth_token="undefined"; is that normal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants