-
Nov 22nd, 2018, 11:30 AM
#1
[RESOLVED] Google Photos API using .NET and REST
Hello all,
I've been given a task to do some research on fetching photos from Google (Google Photos). I did some investigation and made some Proof of concepts but unsuccessful due to the following details below:
a. Picasa API - not working (not working in Console App)
* This has been retired (Shutdown early next year)
b. Google.Apis.PhotosLibrary.v1
- C# released in error and is not supported
The latest API developers.google.com/photos/library/guides/overview states that only Java and PHP is supported.
Is there any way that I can fetch photos in .NET? If not, what options are available? Using JavaScript Frameworks such as Angular/Node/React?
Regards,
KGComputers
Last edited by KGComputers; Jan 30th, 2019 at 03:02 AM.
-
Nov 23rd, 2018, 02:18 PM
#2
Re: Google Photo API
Originally Posted by KGComputers
Actually it doesn't.
It seems pretty clear that they only provide premasticated code for Java and PHP, most likely because those are perceived as high-usage client languages in their target demographic. But I see no hint at that site that these are anything but wrapper libraries around the REST API.
You probably have everything you need to perform the OAuth 2.0 and RESTful operations yourself or even to construct your own language binding if you need to make repeated use of this web service.
-
Nov 24th, 2018, 09:43 AM
#3
Re: Google Photo API
Right.I believe I misunderstood the docs. What I forgot to specify was I have to do it through a windows service to fetch the files through the API. While browsing through the code samples in github, it's developed in Node.JS and basically had a rough time converting it to .NET functionality.
Another option I found out is the Google Drive instead of Google Photos since it has an existing .NET API (C#) which can be added to Visual Studio Project through NuGet. I'll post some updates if I'll be making progress on this.
Regards,
KGC
Last edited by KGComputers; Nov 24th, 2018 at 09:50 AM.
-
Dec 8th, 2018, 10:13 AM
#4
Re: Google Photo API
Ok, I've done a proof of concept application using C# to use google drive instead of photos and submitted them to the client. However, the phones used by the clients are configured using google photos therefore making my proposal as invalid. I'll mark this thread as resolved and will post related questions on consuming the REST API service of Google Photos either in C# or VB.NET subforum.
- kgc
-
Jan 30th, 2019, 01:56 AM
#5
Re: [RESOLVED] Google Photo API
Update.
I've written two blog posts with code examples written in C# and VB.NET on how to access the media items of Google Photos API library using REST.
Read Files From Google Photos Using Google Photos API, REST and C#.NET
Read Files From Google Photos Using Google Photos API, REST and VB.NET
This will serve as reference to other developers.
- kgc
-
Feb 13th, 2019, 08:37 AM
#6
New Member
Re: [RESOLVED] Google Photo API
Originally Posted by KGComputers
Hello, I have tried this example in C#, I manage to sign in into my google account through my c# app, but in this line "HttpWebResponse response = httpWebRequest.GetResponse() as HttpWebResponse;" I get exception "The remote server returned an error: (403) Forbidden." Do you know why this happens?
-
Feb 14th, 2019, 02:41 AM
#7
Re: [RESOLVED] Google Photos API using .NET and REST
Hello, I have tried this example in C#, I manage to sign in into my google account through my c# app, but in this line "HttpWebResponse response = httpWebRequest.GetResponse() as HttpWebResponse;" I get exception "The remote server returned an error: (403) Forbidden." Do you know why this happens?
Hi,
Welcome to the forums!
I encountered the same issue 403 forbidden. Setting credentials(client secret/client id), scopes, token type and access tokens headers with correct values solved the issue for me.
- kgc
Last edited by KGComputers; Feb 14th, 2019 at 03:04 AM.
-
Feb 14th, 2019, 03:22 AM
#8
New Member
Re: [RESOLVED] Google Photos API using .NET and REST
Originally Posted by KGComputers
Hi,
Welcome to the forums!
I encountered the same issue 403 forbidden. Setting credentials(client secret/client id), scopes, token type and access tokens headers with correct values solved the issue for me.
- kgc
Well, I copied client id&secret from this website (https://console.cloud.google.com/apis/credentials - I created new credentials, chose "other" for project type, since I am developing desktop app) and I downloaded json file from here. I tried using my whole email address as well as only username for field "username". I still get the error. For scope I put sharing and readonly, since I want to download photos. Did I miss something?
Thanks in advance for your answer.
Maya
-
Feb 14th, 2019, 05:57 AM
#9
Re: [RESOLVED] Google Photos API using .NET and REST
Yes, you should set the UserName variable with your gmail account. The console application code I presented in my blog should work with desktop apps.
Does the credential.Token.TokenType and credential.Token.AccessToken have values?
- kgc.
-
Feb 14th, 2019, 06:05 AM
#10
New Member
Re: [RESOLVED] Google Photos API using .NET and REST
Originally Posted by KGComputers
Yes, you should set the UserName variable with your gmail account. The console application code I presented in my blog should work with desktop apps.
Does the credential.Token.TokenType and credential.Token.AccessToken have values?
- kgc.
Yes, TokenType is "Bearer" and AccessToken is also read from credentials.json and it is not empty string.
-
Feb 14th, 2019, 08:17 AM
#11
Re: [RESOLVED] Google Photos API using .NET and REST
Yes, TokenType is "Bearer" and AccessToken is also read from credentials.json and it is not empty string.
Hmmmm, maybe you should do review of how you setup your project/account and do some debugging and stuff. And if you discovered the fix for 403 forbidden in your end, then post it here also.
Thanks.
- kgc
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|