Google Cloud Platform 서비스 계정 및 키 파일을 사용하여 .NET에서 Google 스토리지에 oauth-2 연결을 설정하는 방법은 무엇입니까? 사용 가능한 예제 및 설명서는 서비스 계정을 다루지 않으며 API가 혼란스럽고 자주 변경되는 것처럼 보이므로 기존의 설명서를 의심스럽게 만듭니다. 중요한 API 네임 스페이스 및 버전을 포함하여 작업 코드 예제가 가장 좋습니다.Google Cloud Platform 서비스 계정 및 키 파일을 사용하는 .NET의 Google 스토리지
1
A
답변
1
Cloud Storage JSON API documentation의 코드 샘플은 GOOGLE_APPLICATION_CREDENTIALS을 다운로드 한 JSON 키를 가리 키도록 설정 한 후에 Application Default 자격 증명을 사용하는 경우 만 다루고 있습니다.
public StorageService CreateStorageClient()
{
String serviceAccountEmail = "SERVICE_ACCOUNT_EMAIL_HERE";
var certificate = new X509Certificate2(@"key.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { StorageService.Scope.DevstorageFullControl }
}.FromCertificate(certificate));
var serviceInitializer = new BaseClientService.Initializer()
{
ApplicationName = "Storage Sample",
HttpClientInitializer = credential
};
return new StorageService(serviceInitializer);
}
동일한에게 :
그러나 당신은 클라우드 스토리지의 문서에 주어진 CreateStorageClient() 메소드를 적용하는 데 사용할 수있는 수출 P12 키와 서비스 계정을 사용하기위한 documentation for the Google API Client Library for .NET에 샘플이 API docs에 따라 직접 JSON 키 사용 방법 : 나는 현재 .NET dev에 환경이 설정되어 있지 않는 한
public StorageService CreateStorageClient()
{
GoogleCredential credential;
using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream)
.CreateScoped(StorageService.Scope.DevstorageFullControl);
}
var serviceInitializer = new BaseClientService.Initializer()
{
ApplicationName = "Storage Sample",
HttpClientInitializer = credential
};
return new StorageService(serviceInitializer);
}
참고 나는이 테스트를하지 않은,하지만 일반적인 아이디어를 줄 것이다 어떻게 작동하는지. Cloud Storage 문서에 대한 업데이트를 요청하여 JSON 키를 사용하는 예를 추가합니다.
+0
근본적인 문제에 대한 해결 방법을 개발 한 이래로이 솔루션을 검증하기까지는 다소 시간이 걸릴 수 있습니다. –
관련 문제
- 1. Google Cloud Platform 계정 정보를 가져올 Google API가 있습니까?
- 2. Google Cloud Platform - 통합 라이브러리
- 3. Google Cloud Platform KVM 지원
- 4. Google App Engine 및 Google 스토리지
- 5. Google Cloud dataproc에서 기본이 아닌 서비스 계정 사용
- 6. 내 조직과 함께 로그인 Google Cloud Endpoints를 사용하는 Google 계정
- 7. Google 드라이브에 파일을 업로드하는 서비스 계정 인증
- 8. 모바일 클라우드 용 Google Cloud Platform
- 9. Google Cloud Platform : "Google Stackdriver 모니터링 에이전트 업데이트"
- 10. Google Cloud Platform 시스템 상태 페이지
- 11. Google Cloud Storage 인증
- 12. Google 애널리틱스의 서비스 계정 사용
- 13. Google 서비스 계정 위임
- 14. Android : Google Cloud Storage API의 SQLite 스토리지
- 15. Google Cloud Endpoints : XML 서비스
- 16. Python의 Google Cloud Endpoints에 Google 계정 인증을 추가하는 방법
- 17. Go에서 JWT를 사용하는 Google 서비스 계정 승인
- 18. Google Cloud Platform 프로젝트에 대한 관리자 액세스 처리
- 19. Google 드라이브 API 및 서비스 계정
- 20. Google App Engine 및 서비스 계정
- 21. Google 서비스 계정 - Google Analytics API v3
- 22. Google 클라우드 서비스 계정의 개발자 키 받기
- 23. GAE 및 Google Cloud SQL을 사용하는 PhP
- 24. 퓨전 테이블 및 Google 서비스 계정
- 25. Youtube Analytics 및 Google 서비스 계정
- 26. Google Cloud Storage가 Google Apps에서 작동하지 않습니까?
- 27. Google Cloud Platform App Engine 인스턴스의 상태 알림을 설정하려면 어떻게해야하나요?
- 28. google dataproc의 서비스 계정 변경
- 29. Google api 서비스 계정 Client_Secret
- 30. Google 드라이브 API 서비스 계정
DotNetOpenAuth /? https://github.com/DotNetOpenAuth/DotNetOpenAuth/wiki/Security-desktop – weismat
@weismat 살펴 보겠습니다. 지금은 다른 방식으로 핵심 과제를 해결하고 있습니다. Google은 .NET 개발을 쉽게 할 수있는 인센티브가 없습니다. –