2017-02-07 2 views
0

ASP.NET MVC에서 Google 캘린더를 사용하고 있는데 web.config 파일처럼 client_secret.json 파일을 루트 폴더에 두었습니다. 내가 실행 한 후 나는 그것이 내가 푸른 VM에서, 그것은 잘 작동되는 것을 사용하고 있습니다 때마다Google 캘린더 API를 사용하는 방법

unable to found the client_secret.json. 

같은 오류를 던지고있다 구글 캘린더를 연결하는 인터넷이나 모바일 브라우저에서 응용 프로그램을 검색하고

그 응용 프로그램 인터넷이나 모바일 브라우저가 잘 작동합니다. 아래는 Google 캘린더를 연결하는 데 사용한 코드입니다. 아래 코드를 확인하고 내가 잘못하고있는 것을 제안 해 주시겠습니까? 당신이 .NET Quickstart를 수행하면

using (var stream = new FileStream(@"D:\Connectgoogle\client_secret.json" 
            , FileMode.Open 
            , FileAccess.Read)) 

, 당신이 당신의 작업 내부의 client_secret.json 이동 :

UserCredential credential; 
using (var stream = new FileStream(@"D:\Connectgoogle\client_secret.json" 
            , FileMode.Open 
            , FileAccess.Read)) 
{ 
    credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
     GoogleClientSecrets.Load(stream).Secrets, 
     new[] { CalendarService.Scope.Calendar }, 
     "LookIAmAUniqueUser", 
     CancellationToken.None, 
     new FileDataStore(@"c:\datastore", true) 
    ).Result; 
} 

답변

1

여기 문제가 client_secret.json의 디렉토리 코드에서이 부분 생각 디렉토리 :

a. client_secret.json (1 단계에서 다운로드)을 Visual Studio Solution Explorer로 드래그합니다.

using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) 

확인 전체 코드 구현을위한 빠른 링크 :

과 프로그램은 원하는 찾기 위해 하나가 될 것입니다.

관련 문제