簡體   English   中英

Xamarin android 應用程序中的 Google.Drive.Api Oauth 2 憑據

[英]Google.Drive.Api Oauth 2 Credientials in Xamarin android application

我正在嘗試使用我的 xamarin android 應用程序使用 google.drive.api 從 google 驅動器讀取文件,后者請求 Android 的 Google Oauth2 ID 憑據被授權訪問 Google 驅動器。

調試在這里停止:

credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets
                {
                    ClientId = "My-Client-ID",
                    ClientSecret = null
                },
                Scopes,
                "user",
                CancellationToken.None,
                new FileDataStore(credPath, true)).Result;

並引發和異常:

System.AggregateException: '發生一個或多個錯誤。 (無法使用“https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=MY-CLIENT-ID&redirect_uri=http%3A%2F%2F127.0.0.1%3A46401 %2Fauthorize%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.readonly" 用於授權。有關詳細信息,請參閱內部異常。)'

注意:在使用桌面應用程序的 Oauth ID 的桌面控制台應用程序上嘗試它時效果很好。

GoogleWebAuthorizationBroker.AuthorizeAsync旨在僅用於已安裝的應用程序。 google .net 客戶端庫不支持 Xamarin 身份驗證。 從庫的自述文件中可以看出。

在此處輸入圖像描述

您將無法使用此庫進行身份驗證。 您將不得不自己編碼授權。 我過去曾為客戶做過這件事,這是可行的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM