- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
授权访问 gmailAPI 的凭据似乎以某种方式缓存。当我更改客户端 ID 和密码以及电子邮件地址时,没有任何变化。此外,当我更改范围时,没有任何变化。我正在尝试强制刷新凭据。有没有办法强制凭据重新提示用户?
是否有我可以找到并删除的文件?
我正在使用 c# 和来自 nuget 的 gmail api 包。认证代码是:
_emailAddress = Settings.EmailAddress;
string clientSecret = Settings.ClientSecret;
string clientId = Settings.ClientId;
ClientSecrets clientSecrets = new ClientSecrets {ClientId = clientId, ClientSecret = clientSecret};
UserCredential credential;
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
clientSecrets,
Scopes,
"user",
CancellationToken.None).Result;
_service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Draft Sender", //applicationName,
});
此外,一旦我获得凭证,我的范围就设置好了:在我删除并更新 secret 和客户端 ID 之前,无法更改范围。此外,它需要两次运行才能生成凭据,第一次导致错误,但第二次导致授权提示。
我很确定发生这种情况是因为凭据以某种方式缓存在某个地方,即使我没有指定任何存储...但我不确定。无论哪种方式,问题似乎都取决于 gmail api 包中的代码,但我无法为我正在处理的问题找到解决方案。
最终,我需要将一个功能部署到一个 ASP 网站,该网站将访问 gmail 帐户作为电子邮件的存储库,因此我需要弄清楚这个授权问题,以便服务器在部署时可以访问电子邮件帐户(或之后很容易)。在没有中间错误的情况下发生这种情况并不是真的必要(但需要)。
是否有解决方案(简单或困难)来控制此缓存过程并处理权限?
最佳答案
如果您没有指定存储响应 token 的位置,它将存储在:
C:\Users\'你的用户'\AppData\Roaming\Google.Apis.Auth
如果你想指定目录看这个:(注意:你只需要在你的项目中创建目录App_Data
)
string path = HostingEnvironment.MapPath("~/App_Data");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "Client_ID",
ClientSecret = "Secret_Client"
},
Scopes,
"me",
CancellationToken.None,
new FileDataStore(path)
).Result;
关于c# - Gmail API : forcing the authorization to reprompt the user,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30647864/
我通过 React 开发了一个网页,其中 Webchat-Bot 和 React App 进行交互。 React 应用程序包含一个计时器,它应该停止在那一刻运行的任何对话框。它通过 Direct-Li
授权访问 gmailAPI 的凭据似乎以某种方式缓存。当我更改客户端 ID 和密码以及电子邮件地址时,没有任何变化。此外,当我更改范围时,没有任何变化。我正在尝试强制刷新凭据。有没有办法强制凭据重新提
我是一名优秀的程序员,十分优秀!