【问题标题】:Skip web authentication of gmail api跳过 gmail api 的 web 身份验证
【发布时间】:2018-06-29 15:38:04
【问题描述】:

我正在开发电子邮件应用程序以读取来自 Gmail 的特定邮件,因为我正在使用以下代码。

 using (var stream = new FileStream(userCredentialLocation + CredentialsJasonFile, FileMode.Open, FileAccess.Read))
   {
      string credPath = userCredentialLocation;    
      credPath = Path.Combine(credPath, ".credentials/gaf-gSuite.json");
      credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                        GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None,
                        new FileDataStore(credPath, true)).Result;

                    Console.WriteLine("Credential file saved to: " + credPath);

            }

但它正在启动 Gmail 应用程序以提供访问权限,但我想跳过人工交互,例如提供命令行访问权限。

请任何人帮助我。

【问题讨论】:

    标签: .net gmail-api


    【解决方案1】:

    这是授权您的应用流程的固有部分:

    使用 Gmail 授权您的应用程序对 Gmail API 的所有请求都必须是 由经过身份验证的用户授权。 Gmail 使用 OAuth 2.0 protocol 验证 Google 帐户并授权访问用户数据。 您还可以使用 Google+ 登录来提供“使用 Google 登录” 您的应用的身份验证方法。

    如果它适合您,您可以尝试 Google Sign-in 替代方案。

    【讨论】:

      猜你喜欢
      • 2017-11-24
      • 1970-01-01
      • 2018-10-25
      • 2020-07-11
      • 1970-01-01
      • 2017-10-22
      • 2014-01-28
      • 2012-06-16
      • 2016-07-03
      相关资源
      最近更新 更多