The web client uses $http.post to communicate with my server to initiate the Twitter authorization. In my asp.net mvc app, I use this LinqToTwitter code:
var auth = new MvcSignInAuthorizer
{
CredentialStore = new SessionStateCredentialStore
{
ConsumerKey = ConfigurationManager.AppSettings["TwitterKey"],
ConsumerSecret = ConfigurationManager.AppSettings["TwitterSecret"],
OAuthToken = null,
OAuthTokenSecret = null,
UserID = 0,
ScreenName = null
}
};
string twitterCallbackUrl = ....; // My server callback here
return await auth.BeginAuthorizationAsync(new Uri(twitterCallbackUrl));
When this goes back to the client, nothing happens and I see an error message in the console:
XMLHttpRequest cannot load https://api.twitter.com/oauth/authenticate?oauth_token=[...]. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
When using the facebook API, the server was able to get the facebook auth URL and return it with a json response. I could then redirect myself in my angular code. But here I use BeginAuthorizationAsync which returns a 3032 with the auth url put in the headers's Location field.
How can I handle this on the angular side? Can I get the full oauth url with the oauth token from LinqToTwitter to simply return it as json, like with facebook?
PS: I know I can use a form POST to solve this but I'm trying to keep my angular solution to avoid forms in my web page.
Thanks