Question

I have a weird problem with external google authentication. Basically I'm using almost the same code which is generated by default MVC4 internet application. Everything works fine on my local machine. I can login with google account.

But when I change the connectrion string to external database on the web, this code:

OAuthWebSecurity.Login(result.Provider, result.ProviderUserId, createPersistentCookie: false)

returns FALSE so it's not logging in, and I don't know any reason why. The same happens when I publish whole website on the web (with the same extenral connection string which seems to generate the problem on my local machine).

The ONLY difference between working and not working version is different connection string in web.config.

Did anyone suffer the same problem?

EDIT

I didn't mention. The other connection string works correctly. It gets all the data from database, but somehow google authentication silently fails. It just does not log in. Database schema and the data is identical to my local database (I have even generated sql script with data and applied in on external database) Also the user which I want to log in is in this external database.

So what is happening: OAuthWebSecurity.Login returns false so I automatically want to register new user, but then the user is found already in database and I'm getting something like "the user already exists in database".

Very weird.

Was it helpful?

Solution

Did you create the user in external DB with CreateOrUpdateAccount method? Probably you do not have associated any user with the Google credentials which you are using...

The login process works in following steps:

  1. Hey Google, tell me who is logged in.
  2. Google tells you some UserId X
  3. OAuthWebSecurity asks your membership provider for user with GoogleUserId X
  4. If there exists such a user, it logs him in and if not, login fails...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top