Oauth 2.0 使用BackgroundDownloader下载Google驱动器文件-Windows Phone(通用)

Oauth 2.0 使用BackgroundDownloader下载Google驱动器文件-Windows Phone(通用),oauth-2.0,windows-phone-8.1,Oauth 2.0,Windows Phone 8.1,我正在尝试使用BackgroundDownloader下载Google驱动器文件。我已经使用RESTAPI验证了用户进入驱动器的身份,并获得了访问令牌。我的登录逻辑是这样的 public async Task<bool> SignIn() { var googleUrl = new StringBuilder(); googleUrl.Append("https://accounts.google.com/o/oauth2/auth?c

我正在尝试使用BackgroundDownloader下载Google驱动器文件。我已经使用RESTAPI验证了用户进入驱动器的身份,并获得了访问令牌。我的登录逻辑是这样的

    public async Task<bool> SignIn()
    {
        var googleUrl = new StringBuilder();
        googleUrl.Append("https://accounts.google.com/o/oauth2/auth?client_id=");
        googleUrl.Append(Uri.EscapeDataString(GoogleConstants.ClientId));
        googleUrl.Append("&scope=https://www.googleapis.com/auth/drive");
        googleUrl.Append("&redirect_uri=");
        googleUrl.Append(Uri.EscapeDataString(GoogleConstants.CallbackUrl));
        googleUrl.Append("&state=foobar");
        googleUrl.Append("&response_type=code");

        var startUri = new Uri(googleUrl.ToString());
        WebAuthenticationBroker.AuthenticateAndContinue(startUri, new Uri(GoogleConstants.CallbackUrl), null, WebAuthenticationOptions.None);
        return true;
    }
但我犯了未经授权的错误。我应该如何将我的访问令牌传递给BackgroundDownloader


[我不想使用任何第三方SDK进行身份验证和下载。]

最后我发现了问题。这是我在请求中错过的令牌类型。标题应该是这样的

downloader.SetRequestHeader("Authorization", "Bearer" + "accesstoken");

是否确实正确格式化了授权标头?您可以尝试按照以下步骤查找有关错误的信息:
downloader.SetRequestHeader("Authorization", "Bearer" + "accesstoken");