Tag: oauth

使用Google表格API和服务帐户时禁止使用403

我有一个使用服务帐户的应用程序(因为它从一个cron作业运行,因此我无法通过浏览器中的用户进行授权)。 以下是我创建工作表服务的方法: private static final String APPLICATION_NAME = “my app”; private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance(); private static HttpTransport HTTP_TRANSPORT; static { try { HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); } catch (GeneralSecurityException | IOException e) { e.printStackTrace(); } } private static final List SCOPES = Collections.singletonList(SheetsScopes.SPREADSHEETS); private static Credential authorize() throws IOException, GeneralSecurityException { GoogleCredential credential […]

如何在部署的appengine数据库中调试eclipse中的服务器代码?

我在Eclipse中有一个Google AppEngine(Java)项目。 我想在Eclipse中调试我的本地代码,但是在AppEngine上使用已部署的数据库。 到目前为止,我使用远程API与用户名/密码(旧方式) 这个方法将被弃用,我想使用OAuth,但是当我尝试使用它时,它会引发exception: java.lang.IllegalStateException: OAuth-based authorization not supported for clients running on App Engine at com.google.appengine.tools.remoteapi.RemoteApiOptions.getOrCreateHttpTransportForOAuth(RemoteApiOptions.java:359) at com.google.appengine.tools.remoteapi.RemoteApiOptions.useApplicationDefaultCredential(RemoteApiOptions.java:162) 当我运行在Eclipse中使用远程api的简单Java客户端应用程序时,可以使用Everthing。 但是如果客户端是Eclipse中的AppEngine开发环境,它就不起作用。 如何使用appengine数据库在eclipse中调试服务器代码? 错误报告: https : //code.google.com/p/googleappengine/issues/detail? id = 12556

OAuthProblem,缺少参数access_token

我在尝试获取用户的访问令牌时遇到此错误。 这与facebook应用程序的授权过程有关。 产生该exception的代码如下: OAuthClientRequest oAuthRequest = OAuthClientRequest .tokenLocation(“https://graph.facebook.com/oauth/access_token”) .setGrantType(GrantType.AUTHORIZATION_CODE) .setClientId(“myAppId”) .setClientSecret(“myAppSecret”) .setRedirectURI(“myAppURL”).setCode(code) .buildBodyMessage(); 下面抛出的exception如下: 12:14:22,468 ERROR [STDERR] OAuthProblemException{description=’Missing parameters: access_token’, error=’invalid_request’, uri=’null’, state=’null’, scope=’null’} 12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.common.exception.OAuthProblemException.error(OAuthProblemException.java:57) 12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.common.utils.OAuthUtils.handleOAuthProblemException(OAuthUtils.java:165) 12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.common.utils.OAuthUtils.handleMissingParameters(OAuthUtils.java:183) 12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateRequiredParameters(OAuthClientValidator.java:90) 12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validateParameters(OAuthClientValidator.java:53) 12:14:22,468 ERROR [STDERR] at org.apache.amber.oauth2.client.validator.OAuthClientValidator.validate(OAuthClientValidator.java:49) 12:14:22,468 […]

使用Android上保存的Dropbox身份validation详细信息

在Dropbox网站上的入门文章中,他们有一个教程如何使用Android API和Android入门。 当应用程序首次启动时,系统会要求用户对软件进行身份validation以使用用户Dropbox帐户。 身份validation成功完成后,您将收到一对身份validation字符串,密钥和密码。 用户validation应用程序使用他或她的Dropbox帐户后,我使用Android的SharedPreferences保存密钥和secred。 如何使用这些保存的值? 我不是指如何使用SharedPreferences检索它们,而是如何使用它们来防止再次重新validation应用程序的需要? 在Dropbox网站上,他们没有提供使用这些的方法。 他们所说的都是 finishAuthentication()方法将用户的访问令牌绑定到会话。 您现在可以通过mDBApi.getSession()。getAccessTokenPair()来检索它们。 在您的应用关闭后,您将再次需要这些令牌,因此保存它们以供将来访问非常重要(尽管此处未显示)。 如果不这样做,用户每次使用您的应用时都必须重新进行身份validation。 实现存储密钥的常用方法是通过Android的SharedPreferences API。

OAuth – 无效令牌:不允许时使用请求令牌

我正在尝试使用OAuth 2.0访问Google的Documents List API 3.0,但我遇到了401错误的麻烦。 用户接受后,我的代码如下: GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters(); oauthParameters.setOAuthConsumerKey(CLIENT_ID); oauthParameters.setOAuthConsumerSecret(CLIENT_SECRET); oauthParameters.setOAuthToken(token); oauthParameters.setOAuthTokenSecret(tokenSecret); oauthParameters.setScope(“https://docs.google.com/feeds/”); service = new DocsService(“myapp”); service.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer()); DocumentListFeed feed = service.getFeed(new URL(“https://docs.google.com/feeds/default/private/full/?v=3”), DocumentListFeed.class); 然后,在最后一行-getFeed() – 抛出exception: com.google.gdata.util.AuthenticationException: Token invalid – Invalid token: Request token used when not allowed. Token invalid – Invalid token: Request token used when not allowed. […]

使用java离线访问谷歌日历

我们有代码将我们的应用程序日历与登录用户的Google日历同步。 该代码使用的是AuthSub和CalendarService类,但它不提供使用访问令牌和刷新令牌的谷歌日历的离线访问,因为我想使用日历类来使用OAuth v3。 我面临的问题是将我的旧代码合并到没有getFeed()函数的新v3 Calendar类。 这是我的应用程序中的一些代码 if(StringUtil.isValid(request.getQueryString())) { onetimeUseToken = AuthSubUtil.getTokenFromReply(request.getQueryString()); } if(StringUtil.isValid(onetimeUseToken)) { String sessionToken = AuthSubUtil.exchangeForSessionToken(onetimeUseToken,null); CalendarService calendarService = new CalendarService(“myapp”); calendarService.setAuthSubToken(sessionToken, null); session.setAttribute(“calendarServicesession”,calendarService); userIDforCalendar = (String) session.getAttribute(“calendar_user_no”); } CalendarFeed myResultsFeed1 =service.getFeed(new URL(“https://www.google.com/calendar/feeds/default/allcalendars/full”),CalendarFeed.class); for (int i = 0; i < myResultsFeed1.getEntries().size(); i++) { CalendarEntry entry = myResultsFeed1.getEntries().get(i); ….. } 请提供一些使用CalendarService进行离线访问的方法,这样我就不必更改代码了。 希望能快速回复。 谢谢 – […]

使用JOAuth进行OAuth 1授权,需要示例

自从我看到有关如何在LinkedIn / Twitter上进行OAuth 1 3-legged或2-legged授权的问题后,我想我会发布一个例子,说明我如何通过JOAuth授权Twitter。

JOAuth,一个基于java的OAuth 1(最终)和OAuth 2(草案10)库。 我该如何使用它?

我在这里看到太多问题(SO)询问OAuth以及如何使用OAuth协议连接到Facebook Graph API或Twitter API。 我发现了JOAuth (来自谷歌代码),我想知道如何使用它? JOAuth提供了哪些其他function,并且与其他java oauth库相比是否能够很好地实现?

Spring Oauth2隐含流量

致力于使用Spring实现Oauth2。 我想实现隐式工作流程: 我的配置文件: @Configuration @EnableAutoConfiguration @RestController public class App { @Autowired private DataSource dataSource; public static void main(String[] args) { SpringApplication.run(App.class, args); } @RequestMapping(“/”) public String home() { return “Hello World”; } @Configuration @EnableResourceServer protected static class ResourceServer extends ResourceServerConfigurerAdapter { @Autowired private TokenStore tokenStore; @Override public void configure(ResourceServerSecurityConfigurer resources) throws Exception { resources.tokenStore(tokenStore); } […]

获取用Java或Groovy填充的有效oauth_signature的绝对最小代码?

所以我正在测试Rest OAuth实现。 我的测试工具将发送HTTP请求,但我需要准备Authorization标头。 我需要的是:我想要一个有效的授权标题 我拥有:除了oauth_signature之外的所有标题我还有2个秘密,即token_secret和consumer_secret。 我也拥有access_token。 所以它真的归结为,必须签署这个请求。 我怎么做? 简介 :我只需要为RESTful服务填充Authorization标头的oauth_signature部分。 我该怎么做? 基本上: oAuthHeader=”OAuth”; oAuthHeader=oAuthHeader+” oauth_signature_method=”+oauth_signature_method; oAuthHeader=oAuthHeader+”,oauth_version=”+oauth_version; oAuthHeader=oAuthHeader+”,oauth_nonce=”+oauth_nonce; oAuthHeader=oAuthHeader+”,oauth_timestamp=”+oauth_timestamp; oAuthHeader=oAuthHeader+”,oauth_consumer_key=”+oauth_consumer_key; oAuthHeader=oAuthHeader+”,oauth_token=”+oauth_token; oAuthHeader=oAuthHeader+”,oauth_signature=”+**oauth_signature**; Authorization = oAuthHeader; 我的问题是我没有oauth_signature部分。 我不知道如何得到它。 请帮助?