Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

External Login using Web API giving Invalid response for Preflight request

$
0
0

Hi,

I'm building a website with Angular for frontend and Asp.Net Web API for the backend. I'm trying to include external login for Google on the site. The steps that I follow are:

  1. From javascript code, I make http call to GET api/Account/ExternalLogins?returnUrl=%2F&generateState=true to get a list of all external login providers.
  2. From the URL that is returned ( /api/Account/ExternalLogin?provider=Google&response_type=token&client_id=self&redirect_uri=https%3A%2F%2Flocalhost%3A44327%2F&state=XXXXXXX ), I make another http call to this url. 
  3. According to this post ( http://hintdesk.com/c-use-asp-net-identity-external-authentication-with-desktop-application/ ), this should automatically redirect to the Google's sign-in page. 
  4. But I'm getting this error on Chrome debugger console: 

XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=XXXXXXX&redirect_uri=https%3A%2F%2Flocalhost%3A44327%2Fsignin-google&scope=openid%20profile%20email&state=XXXXXX. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://localhost:44327' is therefore not allowed access. The response had HTTP status code 405.

I have already enabled CORS on the Web API.

Thanks in advance!


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images