Results 1 to 11 of 11

Thread: [RESOLVED] Google Photos API using .NET and REST

  1. #1

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Resolved [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.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Google Photo API

    Quote Originally Posted by KGComputers View Post
    The latest API developers.google.com/photos/library/guides/overview states that only Java and PHP is supported.
    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.

  3. #3

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    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.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  4. #4

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    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
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  5. #5

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    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
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  6. #6
    New Member
    Join Date
    Feb 2019
    Posts
    3

    Re: [RESOLVED] Google Photo API

    Quote Originally Posted by KGComputers View Post
    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
    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?

  7. #7

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    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.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  8. #8
    New Member
    Join Date
    Feb 2019
    Posts
    3

    Re: [RESOLVED] Google Photos API using .NET and REST

    Quote Originally Posted by KGComputers View Post
    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

  9. #9

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    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.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  10. #10
    New Member
    Join Date
    Feb 2019
    Posts
    3

    Re: [RESOLVED] Google Photos API using .NET and REST

    Quote Originally Posted by KGComputers View Post
    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.

  11. #11

    Thread Starter
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    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
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width