Oha*_*adR 5 google-calendar-api google-api spring-security oauth-2.0
我在这里搜索了一下,但找不到我的问题的答案.
我使用spring-sec-oAuth 2.0(1.0.0.RC2a)实现oAuth客户端.正确设置beans.xml后,我很高兴得到一个有效的令牌,所有看起来都很好.然后,我想使用Calendar API - 我不知道如何调用以获取Calendar对象.
我的(相关)设置:(spring-servlet.xml)
<!--apply the oauth client context-->
<oauth:client id="oauth2ClientFilter" />
<oauth:resource id="google"
type="authorization_code"
client-id="<my client id>"
client-secret="<my client secret>"
access-token-uri="https://accounts.google.com/o/oauth2/token"
user-authorization-uri="https://accounts.google.com/o/oauth2/auth"
scope="https://www.googleapis.com/auth/calendar"
client-authentication-scheme="form"
pre-established-redirect-uri="https://ohad.sealdoc.com/oauth2-client/hello" />
<bean id="googleClientService" class="com...GoogleClientServiceImpl">
<property name="butkeDemoRestTemplate">
<oauth:rest-template resource="google" />
</property>
Run Code Online (Sandbox Code Playgroud)
和实现类:
public class GoogleClientServiceImpl implements DemoService
{
private RestOperations butkeDemoRestTemplate;
@Override
public String getTrustedMessage()
{
String dataUri = "https://www.googleapis.com/calendar/v3/users/me/calendarList?minAccessRole=writer";
Calendar service = butkeDemoRestTemplate.getForObject(dataUri, Calendar.class);
return "demo";
}
}
Run Code Online (Sandbox Code Playgroud)
这样做最终得到:
请求处理失败; 嵌套异常是error ="invalid_request",error_description ="{errors = [{domain = usageLimits,reason = accessNotConfigured,message = Access Not Configured}],code = 403,message = Access Not Configured}"
当然,我在"getTrustedMessage()"中做错了,所以我听说咨询专家......我想使用OAuth2RestTemplate,但我怎么知道我应该使用的URI?搜索(谷歌)后,我发现只有谷歌代码的例子,他们使用谷歌oAuth(我不想使用它 - 我宁愿使用Spring实现我的客户端)
有任何想法吗?
| 归档时间: |
|
| 查看次数: |
6320 次 |
| 最近记录: |