Tag: oauth

如何使用Spring-Boot和OAuth2限制特定域登录

我已经使用spring boot和Google成功完成了OAuth2登录,但我想限制登录到特定域(我们正在使用Google Apps for Work)。 我认为我应该通过扩展类OAuth2ClientAuthenticationProcessingFilter( 在此线程中指定)来处理,但我不知道如何做到这一点。 基本上,我想使用Google OAuth 2.0作为身份提供商,但只能接受公司用户(@ company.com)。

使用Scribe在LinkedIn中发布消息,向LinkedIn发送消息

以下是发送post消息的代码。 在我的屏幕上,我有一个EditText部分,允许用户输入文本,当他们点击后,调用sendMessage函数。 我一直在回应中得到这个。 我也尝试过URLEncode.encode(有效载荷,“UTF-8”)来获取一个编码的字符串,以便添加到正文并且不起作用。 任何见解都会有所帮助。 04-19 18:24:50.570: D/response(693): 04-19 18:24:50.570: D/response(693): 400 04-19 18:24:50.570: D/response(693): 1334859891007 04-19 18:24:50.570: D/response(693): WJPI8VXQME 04-19 18:24:50.570: D/response(693): 0 04-19 18:24:50.570: D/response(693): Couldn’t parse share document: error: Unexpected end of file after null 04-19 18:24:50.570: D/response(693): 这是代码: private static final String SendMessage = “https://api.linkedin.com/v1/people/~/shares”; public void sendMessage(View view) { //Get […]

在Web应用程序中实现auth

我想在我的Web应用程序中使用auth应用程序来跳过用户的注册过程。 我正在使用http://code.google.com/p/socialauth/ java库来实现身份validation。我正面临以下问题 我已经和twitter这样的auth提供商创建了密钥。 但我在我的系统上本地运行此应用程序时遇到问题,因为我在生成密钥时提供了我的网站所需的地址。 2.我无法配置我的主机文件,以便在生成密钥时使用我提供的地址属性。 这是执行的代码片段。 package com.auth.actions; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.util.RequestUtils; import org.brickred.socialauth.AuthProvider; import org.brickred.socialauth.AuthProviderFactory; import com.auth.form.AuthForm; public class SocialAuthenticationAction extends Action { final Log LOG = LogFactory.getLog(SocialAuthenticationAction.class); @Override public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest […]

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)因为服务器返回了与内容长度相关的错误。 有任何想法吗? 是否有必要将有效载荷放在一条线上? 怎么样?

尝试在spring应用程序中获取OAuth2访问令牌时找不到404 404

我正在尝试创建一个Web应用程序,我们可以通过调用一些http基本请求来获取“密码”授权类型中的访问令牌 例如 我打电话的时候 HTTP://本地主机:8080 / demo4ssh-安全的oauth2 /的OAuth /令牌的client_id = mobile_1&client_secret = secret_1&grant_type =密码&用户名=张三&密码= 123456? 我可以得到以下令牌 {“access_token”:”4219a91f-45d5-4a07-9e8e-3acbadd0c23e”,”token_type”:”bearer”,”refresh_token”:”d41df9fd-3d36-4a20-b0b7-1a1883c7439d”,”expires_in”:43199,”scope”:”read write trust”} 但是我的令牌网站总是返回404.我尝试在网上进行一些搜索,但仍然没有帮助… 这是我的代码: web.xml中 contextConfigLocation /WEB-INF/security-context.xml org.springframework.web.context.ContextLoaderListener springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* user-dispatcher org.springframework.web.servlet.DispatcherServlet 1 安全的context.xml 我的控制器类 @Controller @RequestMapping(“/operation”) public class UserOperationController { private static final Logger logger = Logger.getLogger(UserOperationController.class); @RequestMapping(“/Login”) public ModelAndView home() { return new ModelAndView(“login”); } […]

Spring Oauth2:在SecurityContext中找不到身份validation对象

我有一个项目,我实现了Spring安全性和Spring OAuth2 Security。当我请求访问令牌时,它运行良好但是当我使用访问令牌请求资源时,我得到了“在SecurityContext中找不到身份validation对象”。 我的项目的SecurityContext是: <!– –> <!– –> <!– –> <!– –> <!– –> <!– –> <!– –> 我使用http:// localhost:8060 / oauth / token请求令牌?grant_type =密码&client_id = nokia3320&client_secret = 0987654321&username = subash&password = 123456我得到了以下回复 { “access_token”: “9f5a89ce-a0d9-4d65-8e83-5d3b16d8c025”, “token_type”: “bearer”, “refresh_token”: “c2ac82ec-9f41-46dd-b7c2-4772c018505c”, “expires_in”: 499, “scope”: “read trust write” } 当我尝试使用http:// localhost:8060 / Api / currencyList在authorizatioin错误中使用访问令牌访问资源时,我得到了以下响应 { “error”: […]

Magento Rest Oauth API(签名无效)401

当我尝试从Java中获取Magento的数据时,我收到了Signature无效问题。 我的代码出了什么问题: public class MagentoFacade { final String MAGENTO_API_KEY = “apikey”; final String MAGENTO_API_SECRET = “apisecret”; final String MAGENTO_REST_API_URL = “urlmagento/api/rest”; public void testMethod() { OAuthService service = new ServiceBuilder() .provider(MagentoThreeLeggedOAuth.class) .apiKey(MAGENTO_API_KEY) .apiSecret(MAGENTO_API_SECRET) .debug() .build(); System.out.println(“” + service.getVersion()); // start Scanner in = new Scanner(System.in); System.out.println(“Magento’s OAuth Workflow”); System.out.println(); // Obtain the Request Token System.out.println(“Fetching […]

使用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应用程序,如果我向服务器发送消息,则将用户数据与消息一起发送到服务器。 我真的不知道如何做到这一点。 如果你能告诉我,那么我是在正确或错误的轨道上会很棒。 任何建议我都会很高兴。 谢谢,马克

使用twitter4j在Oauth中出现问题

这是我在调用twitter.getOauthRequestToken(callbackUrl) 。 我添加了正确的消费者密钥和消费者秘密。 401:Authentication credentials (https://dev.twitter.com/docs/auth) were missing or incorrect. Ensure that you have set valid conumer key/secret, access token/secret, and the system clock in in sync. Desktop applications only support the oauth_callback value ‘oob’ /oauth/request_token 我多次调试代码,并在上面调用之前找到了所有凭据。 任何使用过twitter4j的人都能指出问题吗? 或者我应该使用另一个oauth库? 有什么建议么?

使用Java和Scribe的Vimeo搜索API

在它的API Vimeo工程师声称我们应该能够在没有访问令牌的情况下进行搜索,我花了好几个小时而不幸的是无法让它工作,我不确定我做错了什么,所以如果你做的话请帮忙这之前。 OAuthService service = new ServiceBuilder().provider(VimeoApi.class).apiKey(consumerString).apiSecret(consumerSecret).build(); OAuthRequest myrequest = new OAuthRequest(Verb.GET,”http://vimeo.com/api/rest/v2format=json&method=vimeo.videos.search&query=fun”); Token mytoken = new Token(“”, consumerSecret); service.signRequest(mytoken, myrequest); Response response = myrequest.send(); 谢谢