Ashok kumar
Ashok kumar

Reputation: 1611

MVC 5 App with Google OAuth2 Sign-on (C#) is not working

I have followed some articles, but all are not clear as google oauth interface is changed.

Verified some articles, and understood something. With this understanding in mind, followed below steps:

Opned URL: console.developers.google.com

Created new project with name: My Super App

Clicked on Google+ API under Overview section, and Enabled the same.

Here is my doubt whether I am doing correct or not

Selected OAuth ClientID option under Credentials section.

Configured Consent screen With email address, and Product name.

Under Create Client ID section, provided below details:

Application type: Web Application

Name: My Super Client App

Authorized Javascript origins: http://localhost:44300/ - sometimes, I have used this option. Later on, now, I am not using this option. Please suggest me if it is mandatory.

Authorized redirect URIs: http://localhost:44300/signin-google

ClientID, ClientSecret have been generated. Used in My MVC app.

But, I am unable to use Google OAuth.

Please suggest me where I'm doing wrong.

Upvotes: 1

Views: 2202

Answers (3)

Qwertz_mcc
Qwertz_mcc

Reputation: 11

Just a suggestion but perhaps you need to enable the api on your google developer console. I did a quick google and this covers it - http://www.c-sharpcorner.com/article/how-to-configure-google-sign-in-for-Asp-Net-mvc-5-part-sixt/

Upvotes: 1

Martine Moses
Martine Moses

Reputation: 31

Go to your Project properties and under the Web tab you'll see the Project URL. In place of the https://localhost:44300/ given in the article replace it with the one specified in Project URL or, if you've overridden that one, use the one specified in the Override application root URL.

In other words, you shall change the URL here:

enter image description here

Upvotes: 3

Abdul Khan
Abdul Khan

Reputation: 363

please follow Asp.net/mvc :MVC5 :Google OpenAuth from where the below steps are taken:

Creating a Google app for OAuth 2 and connecting the app to the project

  1. Navigate to the Google Developers Console.
  2. Click the Create Project button and enter a project name and ID (you can use the default values). In a few seconds the new project will be created and your browser will display the new projects page.
  3. In the left tab, click APIs & auth, and then > Credentials.
  4. Click the Create New Client ID under OAuth. In the Create Client ID dialog, keep the default Web application for the application type.
  5. Set the Authorized JavaScript origins to the SSL URL you used above (https://localhost:44300/ unless you've created other SSL projects) Set the Authorized redirect URI to: https://localhost:44300/signin-google
  6. Click the Consent screen menu item, then set your email address and product name. When you have completed the form click Save. Click the APIs menu item, scroll down and switch on Google+ API.
  7. Copy and paste the AppId and App Secret into the UseGoogleAuthentication method. The AppId and App Secret values shown below are samples and will not work.

Upvotes: 0

Related Questions