0

I´m developing an UWP Windows 10 App and want to display the events from my Google Calendar on a screen, which is connected to my Raspberry Pi. The problem is, that the Google-Calendar-API v3 is not supporting UWP.

There is already a workaround on Google Calendar API for UWP Windows 10 Application One or more errors occurred but somehow a can´t get the code run. I have the same issue, that is mentioned in the comments. But when I replace var redirectURI = "pw.oauth2:/oauth2redirect"; "] to [" var redirectURI = "localhost/urn:ietf:wg:oauth:2.0:oob";] nothing is happening.

What am I doing wrong? Is there another way to get the events from my Google Calendar to my UWP app? Or is there something like a http request?

Thank you!

Raither
  • 1
  • 2

2 Answers2

0

Firstly, the Google API Client Library for .NET is still not support UWP by now.Through REST API is the correct workaround for you.

If you get the following exception on the WebAuthenticationBroker UI,

We cannot connect to the service you need right now. Check your network connection or try this later

Which is same that mentioned in the comment of above thread, you need to troubleshoot the web authentication broker APIs to find the inside reasons. You could review operational logs and review web requests and responses using Fiddler. Details for how to do please reference this tutorial.

Or you could also try to test your request with OAuth for Apps: Windows Samples. This sample demonstrates how you can open the user's browser with your OAuth 2.0 authorization request, without using WebAuthenticationBroker. In that case, you could know if you can login successfully directly with browser. If anything wrong, you could also see the errors inside browser.

One common possible reason is the navigation error, that means something wrong when navigating to your request URL. For example, you may get can’t connect to the proxy server error with the browser. In this case, you could try to off the Use a proxy server option in Settings->Network->Proxy.

If you still cannot resolve your issue by doing above, please provide the inside error details by the way I mentioned. For example, provide the log:

enter image description here

For a completed sample please reference the scenario 4 of the official sample.

Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21
  • Thank you for the help! The code is running by now. I used the client ID from the windows example and put it in the code from the < https://stackoverflow.com/questions/40539180/google-calendar-api-for-uwp-windows-10-application-one-or-more-errors-occurred> The sign in works fine and now my question. How can I get the event list from my Google Calendar to my UWP App? I'll post my code below. Thank you! – Raither May 10 '18 at 11:57
  • @Raither, I saw you deleted your reply which is actually a question. Have you open a new or prepare to edit to update your current question? – Sunteen Wu May 28 '18 at 03:18
0

First of all, perfect guide here . It explains clearly step by step. Also you can follow this application for how to implement. Now regarding your problem; In the sample application, as you can see redirect url is used without localhost. it should look like as below. you can use urn:ietf:wg:oauth:2.0:oob:auto instead urn:ietf:wg:oauth:2.0:oob difference is that auto closes browser and returns back. other one, code needs to be copied manually. And most important here is in the google console when you create a new auth credential you must choose Ios as below. otherwise you cant work with urn:ietf:wg:oauth:2.0:oob:auto. that worked like a charm for me.

enter image description here

var googleUrl = new System.Text.StringBuilder();             
            googleUrl.Append("https://accounts.google.com/o/oauth2/auth?client_id="); 
            googleUrl.Append(Uri.EscapeDataString("your client it")); 
            googleUrl.Append("&scope=openid%20email%20profile"); 
            googleUrl.Append("&redirect_uri="); 
            googleUrl.Append(Uri.EscapeDataString("urn:ietf:wg:oauth:2.0:oob:auto")); 
            googleUrl.Append("&response_type=code"); 
            googleUrl.Append("&include_granted_scopes=true"); 
Emil
  • 6,411
  • 7
  • 62
  • 112