- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的开发环境中,我有一个用户,我刚刚收到了以下范围的 OAuth token 。
public class GoogleCalendarAdapter : ICalendarAdapter {
#region attributes
private readonly ISiteAuthTokenQueryRepository _tokenRepo;
private readonly GoogleCalendarSettings _settings;
private const string APPNAME = "REDACTED";
private const string ACL_OWNER = "owner";
private const string ACL_WRITER = "writer";
#endregion
#region ctor
public GoogleCalendarAdapter(ISiteAuthTokenQueryRepository tokenRepo,
GoogleCalendarSettings settings) {
_tokenRepo = tokenRepo;
_settings = settings;
}
#endregion
#region methods
private GoogleAuthorizationCodeFlow BuildAuthorizationCodeFlow() {
return new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer() {
ClientSecrets = BuildClientSecrets(),
Scopes = BuildScopeList()
});
}
private CalendarService BuildCalendarService(SiteAuthToken token) {
return new CalendarService(new BaseClientService.Initializer() {
ApplicationName = APPNAME,
HttpClientInitializer = BuildUserCredential(token)
});
}
private ClientSecrets BuildClientSecrets() {
return new ClientSecrets() {
ClientId = _settings.ClientId,
ClientSecret = _settings.ClientSecret
};
}
private string[] BuildScopeList() {
return new [] { CalendarService.Scope.Calendar };
}
private UserCredential BuildUserCredential(SiteAuthToken token) {
TokenResponse responseToken = new TokenResponse() {
AccessToken = token.AccessToken,
RefreshToken = token.RefreshToken
};
return new UserCredential(BuildAuthorizationCodeFlow(), APPNAME, responseToken);
}
public async Task<List<Cal>> GetAllWritableCalendars(Guid siteGuid) {
SiteAuthToken token = await GetToken(siteGuid);
CalendarService svc = BuildCalendarService(token);
IList<CalendarListEntry> calendars = svc.CalendarList
.List()
.Execute()
.Items;
return calendars.Where(c => c.AccessRole.Equals(ACL_OWNER, StringComparison.CurrentCultureIgnoreCase) ||
c.AccessRole.Equals(ACL_WRITER, StringComparison.CurrentCultureIgnoreCase))
.Select(c => new Cal() {
Id = c.Id,
Name = c.Summary
})
.OrderBy(o => o.Name)
.ToList();
}
public async Task<Cal> GetCalendar(Guid siteGuid, string calendarId) {
SiteAuthToken token = await GetToken(siteGuid);
CalendarService svc = BuildCalendarService(token);
CalendarListEntry entry = svc.CalendarList
.Get(calendarId)
.Execute();
Cal retVal = new Cal() {
Id = entry.Id,
Name = entry.Summary
};
return retVal;
}
private async Task<SiteAuthToken> GetToken(Guid siteGuid) {
SiteAuthToken retVal = await _tokenRepo.GetSiteAuthToken(siteGuid, Constants.OAUTH_PROVIDER_GOOGLE);
if (retVal == null) {
throw new ApplicationException($"Could not find a SiteAuthToken for specified site (SiteGuid: {siteGuid})");
}
return retVal;
}
#endregion
}
最佳答案
在您描述的情况下,对我有很大帮助的是使用 Google Developer OAuth Playground .默认情况下,您可以使用 OAuthPlayground 本身作为客户端来获取授权(并观察流量)。但诀窍是进入 [设置] 齿轮并选中 [x] 使用您自己的 OAuth 凭据并尝试授权您的客户端的框。 IMO 这是一个非常有用的调试工具,我想确保您了解它。
关于c# - Google Calendar API 返回 invalid_grant 和错误的请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61690118/
我正在尝试向 Google 联系人 API 验证我的应用程序。我已经完成了 Oauth2 流程的第一步并获得了授权码。我正在尝试将此代码交换为访问 token 和刷新 token ,但是当我尝试从 g
我正在尝试将 Google Plus API 集成到我的网络应用程序中。 我能够通过 Google 进行身份验证并获得代码。当我尝试使用 HttpClient 获取 access_token 时,会出
DocuSign documentation通过易于遵循的授权流程进行代码授予。我能够从初始 GET 请求中获取“代码”到/oath/auth,但是当我在 postman 中尝试时,获取 token
我正在尝试使用我的值设置 config.php,但出现此 fatal error : fatal error :未捕获的异常“Google_AuthException”,消息为“获取 OAuth2 访
我一直在尝试创建一个 access_token对于我的 api。我已经 followed the setup并且正在使用 Postman 测试/创建 token 。我似乎无法通过 invalid_gr
我正在尝试从基于站点的 WebService 调用 Azure 托管 WebAPI。基于站点的服务是 adal-angluar SPA,然后必须调用 Azure 中托管的 REST API。来自 AA
我关注了这个资源:https://REDACTED.b2clogin.com/REDACTED.onmicrosoft.com/B2C_1A_DEMO_CLIENTCREDENTIALSFLOW/oa
我正在使用 Java 运行 Analytics-cmdline-sample 应用程序。我使用的是 Maven 2.2.1,我在 Google Api 控制台中创建了 client_Id 和 clie
我关注了这个资源:https://REDACTED.b2clogin.com/REDACTED.onmicrosoft.com/B2C_1A_DEMO_CLIENTCREDENTIALSFLOW/oa
在尝试使用 Active Directory 进行身份验证以检索访问 token 时,我按照以下步骤操作: 1 - 按照以下说明在 Azure 中创建应用程序(步骤 3): https://githu
我想做什么:我正在将 Spotify SDK 实现到我的 iOS 项目中。我已成功收到 Spotify API 的访问 token ,因为我能够使用所述 API 执行搜索艺术家、搜索歌曲和查看播放列表
当 OAuth2Credential 对象尝试刷新其 access_token 时,有时它会收到 invalid_grant 错误,然后变得无法刷新。我使用的代码基于 Google 的 python
我正在创建一个 API 来包装 google oauth。我正在使用谷歌Python客户端库。 api.py 中的代码 from flask import request, g from ..help
我已经查看了关于此主题的其他问题,它似乎与我的错误不符。运行 Google Sheets APIv4 时出现错误: 引发 HttpAccessTokenRefreshError(error_msg,
最近我一直在为这个问题烦恼。 一些背景 使用oauth2client库来管理用户的 token 。 token 用于定期并发执行各种后台任务。 每次这些任务之一即将为用户运行时,我们都会从存储中获取凭
我正在尝试构建一个访问 Google Analytics API 并提取数据的网络应用程序。但是,我在 OAuth 2.0 授权方面遇到了一些问题。 它允许成功的初始访问,但它很快将我踢出并在我点击刷
我正在尝试使用 Mailchimp 的 OAuth 完成身份验证实现,我的访问 token 请求正在获取“无效授权”错误。 使用 ruby HTTParty gem,我将数据发布到 Mailchi
我创建了自己的网站 (www.luig.us)。我为 SQL 服务器创建了一个基本的 IDE,只教 child SQL,DML。 它要求用户在开始时输入用户名和密码以获得使用服务的 token 。 在
在 https://appleid.apple.com/auth/token 中尝试从 Apple 获取 oAuth token 时,我一直收到 invalid_grant 错误接口(interfac
我在我的 Raspberry PI 上使用 Google Cloud Vision API。当我在我的家庭(首次访问云帐户)网络上使用它时,它工作正常,但如果我从不同的网络访问 API,它会引发 to
我是一名优秀的程序员,十分优秀!