Tag: oauth 2.0

如何使用scribe在Grails中为twitter实现仅限应用程序的身份validation?

早些时候我正在使用Twitter API 1.0的GET搜索/推文根据Grails中的#tags获取推文 Map jsonMap = grails.converters.JSON.parse(new URL(‘http://search.twitter.com/search.json?q=%23’ + URLEncoder.encode(tag) + ‘&offset=’ + offset + ‘result_type=mixed&lang=en&page=’ + page).text) 但由于Twitter API版本1.1的变化,现在上述调用需要身份validation。 我想代表应用程序(身份validation)而不是用户身份validation来获取推文。 这可能吗? 我遇到了application-only-auth但无法实现它。 https://dev.twitter.com/docs/auth/application-only-auth 如何在Grails中使用scribe API实现上述。

(Java)下载URL不起作用

我正在努力尝试使用谷歌驱动器API下载文件。 我只是编写应该从我的驱动器下载文件到我的计算机上的代码。 我终于到了一个我经过身份validation的阶段,可以查看文件元数据。 出于某种原因,我仍然无法下载文件。 我得到的downLoadURL看起来像: https://doc-04-as-docs.googleusercontent.com/docs/securesc/XXXXXXXXXXXXXX/0B4dSSlLzQCbOXzAxNGxuRUhVNEE?e=download&gd=true 当我运行代码或将其复制并粘贴到浏览器中时,此URl不会下载任何内容。 但是,在浏览器中,当我删除URL的“&gd = true”部分时,它会下载该文件。 我的下载方法直接来自google drive API文档: public static InputStream downloadFile(Drive service, File file) { if (file.getDownloadUrl() != null && file.getDownloadUrl().length() > 0) { try { System.out.println(“Downloading: “+ file.getTitle()); return service.files().get(file.getId()).executeMediaAsInputStream(); } catch (IOException e) { // An error occurred. e.printStackTrace(); return null; } } else { // The […]

Google的oauth端点正在返回“错误请求”……但为什么呢?

在https://accounts.google.com/o/oauth2/token请求代币时,在搜索“错误请求”的可能原因后浪费了大量时间,我决定问为什么此代码无法获取只是来自服务器的“错误请求”响应…… String url = “https://accounts.google.com/o/oauth2/token”; HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setChunkedStreamingMode(0); con.setRequestMethod(“POST”); con.setRequestProperty(“Host”, “accounts.google.com”); con.setRequestProperty(“Content-Type”, “application/x-www-form-urlencoded”); con.setRequestProperty(“code”, authCode); con.setRequestProperty(“client_id”, “[CLIENT_ID]”); con.setRequestProperty(“client_secret”, “[CLIENT_SECRET”); con.setRequestProperty(“redirect_uri”, “http://localhost:8080/login”); con.setRequestProperty(“grant_type”, “authorization_code”); // Send post request con.setDoOutput(true); 我必须设置con.setChunkedStreamingMode(0)因为服务器返回了与内容长度相关的错误。 有任何想法吗? 是否有必要将有效载荷放在一条线上? 怎么样?

对于预检,响应具有无效的HTTP状态代码401,用于oauth / token

我在spring boot中为CORS实现了Filter。代码如下: – @SpringBootApplication @Component public class Application implements Filter { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; response.setHeader(“Access-Control-Allow-Origin”, “*”); response.setHeader(“Access-Control-Allow-Credentials”, […]

如何使用twitter登录我的Codename one应用程序

我试图在我的Codename一个应用程序中使用twitter登录,但是当我点击登录按钮时它会重定向到twitter,但不会要求凭据,它只会抛出以下错误: 哇那里! 此页面没有请求令牌。 这是我们要求使用您的Twitter帐户的应用程序所需的特殊密钥。 请返回发送给您的网站或应用程序,然后重试; 这可能只是一个错误。 下面是我的代码: twitter.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Oauth2 Tauth = new Oauth2(“https://api.twitter.com/oauth/authenticate?oauth_token”, “XXXXXXXXXXXXXXXXXX”, “https://www.codenameone.com”); Tauth.showAuthentication(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { AccessToken token = (AccessToken) evt.getSource(); Log.p(token.toString()); } }); } }); 所以任何人都知道这段代码有什么问题吗?

java,驱动APIv2,appengine 1.7.3,struts2.3.4.1,OAuth2。 TokenResponseException:400 OK invalid_grant

我收到错误invalid_grant我已经看过googleing arround,但是在这个问题已经有几天了。 错误被抛入: File file = insert.execute(); 我只是想从我的webapp上传文件到google驱动器。 我正在使用服务帐户在API Access(https://code.google.com/apis/console/)中生成的私钥对(.p12): Service account Use service accounts to call Google APIs on behalf of your application instead of an end-user. Learn more Client ID: xxx-xxxxxx.apps.googleusercontent.com Email address: xxx-xxxxxxxxxxx@developer.gserviceaccount.com Public key fingerprints: a108d8713103e09d0013655c9f80458f03e3a38a – Delete… 在Google APis – >驱动SDK(https://code.google.com/apis/console/?api=drive#project:347347146680:drive_sdk)中,我已将此ClientID放入: Drive Integration OAuth Client ID (Required) Enter the Client […]

Android Javamail自定义身份validation

所以,我意识到SASL没有在android中实现,因此javamail oauth2方法不会开箱即用。 但是,根据google api docs for gmail imap( https://developers.google.com/google-apps/gmail/xoauth2_protocol ),获取身份validation令牌,对其进行编码并发送“AUTHENTICATE XOAUTH2”似乎相当简单。 ‘手动到服务器。 我的问题:我想使用javamail IMAP函数(不想处理IMAP协议命令和自我响应),但我需要一种方法来简单地插入正确的身份validation命令 – 而不是传统的登录用户名密码。 可以这样做,最简单的方法是什么? 我可以创建自己的身份validation方法并轻松实现吗? 或者,我可以创建连接,然后将其移交给IMAPStore(怀疑这会在创建和管理连接池时起作用)。 – -编辑 – – 更具体地说,在Imap.protocol.IMAPSaslAuthenticator所依赖的Android中没有实现javax.security.sasl方法。

单一登录以保护REST API和基于Web的内部系统

我需要一些关于如何使用单一身份validation系统保护REST API和基于Web的内部系统的建议。 我正在研究使用的可能性: oAuth 2.0 JA-SIG CAS 自定义实现(实现两个独立的API) 保护REST API并将调用重定向到特定的API实例 validationWeb应用程序用户。

使用Oauth将Java应用程序与GAE应用程序连接起来

我有一个Java应用程序和一个GAE应用程序,它将C2DM消息发送到Android设备。 现在我想让java应用程序的用户能够通过他们的Google帐户登录到GAE应用程序。 我是否正确,我需要使用oauth来实现这一点? 一点点背景: +———–+ +———-+ | JAVA App | send Message to —> | GAE App | +———–+ +———-+ ^ | | Notify Client | —————————- | | [YES] —> Start delivering C2DMessage 我希望我的ASCII图片更容易理解;) 不知何故,我需要允许用户使用他们的google凭据登录java应用程序,如果我向服务器发送消息,则将用户数据与消息一起发送到服务器。 我真的不知道如何做到这一点。 如果你能告诉我,那么我是在正确或错误的轨道上会很棒。 任何建议我都会很高兴。 谢谢,马克

Google Calendar API和OAuth问题

我收到了错误 com.google.gdata.util.AuthenticationException: Unknown authorization header at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535) ~[gdata-core-1.0.jar:na] 尝试通过API访问Google日历数据时。 以下是该错误之前发生的事情。 1)我通过Googlevalidation: final AccessTokenResponse response = new GoogleAuthorizationCodeGrant(httpTransport, jsonFactory, clientId, clientSecret, authorizationCode, redirectUrl).execute(); final GoogleAccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource( response.accessToken, httpTransport, jsonFactory, clientId, clientSecret, response.refreshToken); LOGGER.debug(“response.accessToken: {}”, response.accessToken); this.oauthAccessToken = response.accessToken; … 2)我通过任务API读取了一些数据: this.service […]