【问题标题】:Windows 10 Google OAuth. Unexpected character encountered while parsing value: . Path '', line 0, position 0Windows 10 谷歌 OAuth。解析值时遇到意外字符: 。路径 '',第 0 行,第 0 位置
【发布时间】:2015-08-02 23:40:41
【问题描述】:

我正在使用 Google Auth .net Api 进行客户端身份验证

var clientSecrets = new Uri(SettingsViewModel.GoogleClientSecretsUri);
this.UserCredential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    clientSecrets,
    this.Scopes,
    "user",
    CancellationToken.None
    );

在 Google 登录 webcontrol 回调它抛出的客户端后:

解析值时遇到意外字符:。路径'',行 0,位置 0。

有什么建议可以解决这个问题吗?

【问题讨论】:

  • 我猜一下:谷歌返回的错误页面是 html 内容,而不是 json。
  • 即使在显示正确的同意页面后也会发生这种情况吗?
  • 下载Fiddler并查看您的网络流量

标签: c# windows-10 google-api-dotnet-client google-authentication


【解决方案1】:

我有机会对此进行更多研究, 来自谷歌的 access_token 响应是 GZip 编码的,他们的 API 在构建 json 响应之前不会对其进行解码。 作为一种解决方法,直到修复 lib 文件,您可以在此处使用该解决方案,只需稍作修改 http://blog.kulman.sk/implementing-google-login-in-universal-apps/ ...

        var responseStream = new GZipStream(await auth.Content.ReadAsStreamAsync(), CompressionMode.Decompress);
        var reader = new StreamReader(responseStream);
        var data = reader.ReadToEnd();
        Debug.WriteLine(data);

...

【讨论】:

    猜你喜欢
    • 2018-07-25
    • 2015-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 1970-01-01
    • 1970-01-01
    • 2016-11-13
    相关资源
    最近更新 更多