googleapis / google-api-dotnet-client

Google APIs Client Library for .NET
https://developers.google.com/api-client-library/dotnet
Apache License 2.0
1.35k stars 525 forks source link

Xamarin forms GoogleWebAuthorizationBroker does not return token #1167

Closed ravidixit closed 6 years ago

ravidixit commented 6 years ago

I am creating a .net standard library which can be used for both iOS and Android projects in my Xamarin forms application and then i can use the drive feature to create and read file data in Xamarin forms application.

The code which I have done so far can be found here please let me know if I am doing something wrong or is there a bug

I followed the code provided in the sample link here everything seems fine until I hit this code snipe

`credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true));`

On this my application just stops and there is a message on the console reads to something like this

The files **LOCATION-OF-MY-IOS-APP-DOCUMENT-DIRECTORY/MY-APP-NAME.IOS.app/open** and LOCATION-OF-MY-IOS-APP-DOCUMENT-DIRECTORY/MY-APP-NAME.IOS.app/https:/accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=MY-APP-CLIENT-ID&redirect_uri=http%3A%2F%2F127.0.0.1%3A51115%2Fauthorize%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.readonly do not exist.

Am not really sure what the message stand for but once this is in the console my application just does not proceed any further and am stuck. Please let me know if i am doing anything incorrect here.

MelbourneDeveloper commented 6 years ago

I also need to get integration working with Xamarin Forms. But, I doubt that the library supports Xamarin Forms at all. I logged this bug: https://github.com/google/google-api-dotnet-client/issues/1173

If you do get Xamarin Forms working at all, I'd really like to hear about it.

My guess is that the .NET Standard library assumes that it has access to pop up a browser for oAuth, but actually doesn't have that ability in Xamarin Forms.

bykovme commented 6 years ago

I'm developing the app using Xamarin.Forms and I want to integrate it with google drive, have the same issue in Xamarin Forms for iOS & Adnroid (but it works as expected for Desktop Mac version).

chrisdunelm commented 6 years ago

This library does not currently support Xamarin. There are a number of reasons for this, but one reason is indeed as @MelbourneDeveloper says, it doesn't have the correct code to launch a browser on mobile platforms.

chrisdunelm commented 6 years ago

Closing this issue, as Xamarin is not a supported platform.

XceSx6 commented 5 years ago

You might wanna use Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) as the credPath At least now i get the next error stating it could not launch the browser with the needed URL ... :x