2017-04-19 1 views
0

webforms 프로젝트에서 Google 로그인으로 리디렉션되는 버튼을 만들고 싶습니다. 사용자가 기록한 후에 이메일과 이름과 같은 그의 프로필에서 기본 데이터를 얻고 싶습니다. asp.net webforms google login하지만 문제가 엉있다 (심지어 에러 (401)를 반환 기본 예 엉) webforms 프로젝트에 Google 로그인 통합

는 난이 [Nemiro] [1]

[1] 시도. 하지만 로컬 호스트,

나는이

var credentials = 
        GoogleWebAuthorizationBroker.AuthorizeAsync(
          new ClientSecrets { ClientId = "client-Id", ClientSecret = "client-secret" }, 
          new[] { "openid", "email" }, "user", CancellationToken.None,null); 

을 시도하고 작동합니다. 리디렉션 URI를 변경하는 방법을 알지 못하기 때문에 서버에 업로드 할 때 작동하지 않을 것이라고 생각합니다.

또한 YouTube에서 IAppBuilder를 Google에 연결하는 것을 보았지만 프로젝트에서 사용할 수 없습니다.

답변

0

귀하는이 사이트뿐만 아니라 귀하의 응용 프로그램에서도 귀하의 고객 ID와 비밀 정보를 삭제할 수 있습니다. 다음 해결책은 나를 위해 작동합니다 :

var googleoptions = new GoogleOAuth2AuthenticationOptions 
     { 
      ClientId = ConfigurationManager.AppSettings["gid"], 
      ClientSecret = ConfigurationManager.AppSettings["gsecret"] 
     }; 
     googleoptions.Scope.Add("https://www.googleapis.com/auth/plus.me"); 
     googleoptions.Scope.Add("https://www.googleapis.com/auth/plus.login"); 
     googleoptions.Scope.Add("https://www.googleapis.com/auth/userinfo.email"); 
     googleoptions.Scope.Add("https://www.googleapis.com/auth/userinfo.profile"); 
     app.UseGoogleAuthentication(googleoptions); 

appsettings에 ID와 암호를 저장하는 것을 잊지 마십시오.

가 로컬 호스트가 아닌 다른 위치에 작동하게하려면 Developersconsole of google

+0

한 문제의 목록에 해당 URL을 추가해야합니다. "앱"은 누구이며 단추와 어떻게 관련시킬 수 있습니까? –

+0

"app"는 시작 구성에 추가 된 IAppBuilder입니다. "app_start"-> "startup.auth.cs" –

+0

폴더가 없으므로 시작을 수정할 수 없습니다. –