示例#1
0
        public GooglePhotosClientTests()
        {
            this.httpClient     = new Mock <HttpClient>();
            this.userCredential = new Mock <UserCredential>();
            GooglePhotosClientSettings clientSettings = new GooglePhotosClientSettings(
                this.httpClient.Object,
                this.userCredential.Object);

            this.googlePhotosClient = new GooglePhotosClient(clientSettings);
        }
示例#2
0
        public GooglePhotosClientIntegrationTests()
        {
            HttpClient     httpClient = new HttpClient();
            UserCredential userCredential;

            using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
            {
                userCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    new[] { "https://www.googleapis.com/auth/photoslibrary.readonly" },
                    "user",
                    CancellationToken.None).Result;
            }

            userCredential.RefreshTokenAsync(CancellationToken.None).Wait();
            GooglePhotosClientSettings clientSettings = new GooglePhotosClientSettings(httpClient, userCredential);

            this.googlePhotosClient = new GooglePhotosClient(clientSettings);
        }