我的集成测试如下所示:
class OAuthTest < ActionDispatch::IntegrationTest
...
@client = OAuth2::Client.new(
client_id,
client_secret,
{ :site => 'https://provider', :token_url => '/oauth/access_token' }
)
@client.connection.build do |b|
b.adapter :action_dispatch, self
end
access_token = @client.auth_code.get_token(...)
access_token.get("/user.json")
Run Code Online (Sandbox Code Playgroud)
使用法拉第0.7.6它工作正常,action_dispatch适配器将http请求路由到我的Rails应用程序(调用users_controller).但是在Faraday 0.8.0的情况下,action_dispatch适配器被替换为rack(请参阅https://github.com/technoweenie/faraday/pull/134),我无法使其正常工作.
我想我需要将上面的代码更改为:
@client.connection.build do |b|
b.adapter :rack, self.app
end
Run Code Online (Sandbox Code Playgroud)
但是它在Rack(1.2.5)没有期待一个Stream,但它获得了一个Hash并undefined read method for Hash在第149行说道(这里:https://github.com/rack/rack/blob/1.2.5/lib/rack/request .rb#L149).
我怎样才能做到这一点?
在我的程序中,我使用WebBrowser控件进行OAuth.它位于vk_auth_window表格上.所以在我打电话的代码中vk_auth_window.WebBrowser1.Navigate(vkauthurl).如果身份验证成功,我会默默地获取令牌,但如果用户未经过身份验证,vk_auth_window则会向他们显示一个表单以输入用户名和密码.为了检查这一点,我捕获_DocumentComplete事件并检查正确的URL.在用户完成身份验证或关闭身份验证表单之前,我不需要执行任何其他代码.ShowDialog()可以解决这个问题,但它在某种程度上隐藏了WebBrowser控件中用户名和密码字段的光标.所以我Dim showform as Boolean=True在_DocumenComplete事件中引入了一个变量并将其设置为False,在主代码中我使用了无限循环.
While showform
System.Threading.Thread.Sleep(100)
Application.DoEvents()
End While
Run Code Online (Sandbox Code Playgroud)
然而,由于线程休眠,它使用户输入变慢.如果我删除它们,它会加载CPU相当多.有没有更好的方法等待表格关闭?它是什么?
我有一个项目规范,可以RESTful地访问第三方远程API并需要oAuth.规范包括以下文本:
访问API需要使用OAuth协议.每个组织的共享密钥/访问密钥组合可防止未授权方访问.由于服务端点标识组织,因此不希望在封装REST请求的OAuth标头中传递其他参数.
其中,我不完全理解以下内容:
由于服务端点标识组织,因此不希望在封装REST请求的OAuth标头中传递其他参数.
我正在构建一个WP7 Twitter客户端.正常的OAuth 1.0流程涉及通过使用我的应用程序的使用者密钥将Web浏览器导航到https://api.twitter.com/1/oauth/authenticate来获取请求令牌; 此页面将显示登录提示,并要求用户授权我的应用程序代表他们执行操作.完成后,此页面将重定向到我的应用程序提供的回调URL,并将请求令牌作为参数提供.
对于网络应用,这是有道理的.我不明白这应该如何适用于独立的移动/桌面应用程序.Twitter API文档似乎暗示这应该是一个可行的选择.它们确实提供了另一种xAuth机制,允许应用程序自己收集用户名/密码,然后直接提供它以获取访问令牌.API文档指出这是一个较差的选项(因为它要求用户信任应用程序,而不仅仅是Twitter,使用他们的密码),但我不知道我有什么合理的选择?
(还有一个基于PIN的选项,但这对用户来说是一个非常繁重的解决方案)
我只是想确保我没有遗漏任何明显的东西.
请检查这个问题Python oauth2 - 提出请求我正在使用我的Web应用程序中的vimeo集成.
起初,我得到了一个oauth_signature和我没有问题(没有错误),我想这些事情再一次从第一,现在我越来越ValueError异常:需要超过1的值来解压缩,而提出这个要求
>>> r = request.get(url, headers=headers)
Run Code Online (Sandbox Code Playgroud)
你可以在这里查看我的代码https://gist.github.com/2949182
错误是
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/requests-0.10.1-py2.7.egg/requests/api.py", line 51, in get
return request('get', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-0.10.1-py2.7.egg/requests/api.py", line 39, in request
return s.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-0.10.1-py2.7.egg/requests/sessions.py", line 159, in request
headers[k] = header_expand(v)
File "/usr/local/lib/python2.7/dist-packages/requests-0.10.1-py2.7.egg/requests/utils.py", line 152, in header_expand
for i, (value, params) in enumerate(headers):
ValueError: need more than 1 value to unpack
Run Code Online (Sandbox Code Playgroud)
谢谢! …
如果用户想要从我们的服务中移除他/她自己,我们会从我们的数据库中删除他们的所有数据,包括Oauth令牌.我们拥有的Oauth令牌是安全和持久的.作为最佳做法的一部分,我们希望将令牌完全无效,就好像他们想要使用Google帐户页面并将其删除一样.阅读Oauth文档我不清楚这是否可能,因为所有的例子都涉及单会话或非安全案例(并且原谅我缺乏"你尝试了什么?" - ism但我正在尝试快速计划如何做到这一点).
所以
1)这可能吗?最好是1.0?
2)怎么做?
我正在尝试按照此指南在我的网络应用程序中使用Youtube api https://developers.google.com/youtube/2.0/developers_guide_protocol_oauth2#OAuth2_Server_Side_Web_Applications_Flow我已成功完成第3步并获得**授权码**.
现在我坚持向这个网址发出POST请求 https://accounts.google.com/o/oauth2/token
我想提出这样的请求:(取自我上面给出的链接)
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=4/ux5gNj-_mIu4DOD_gNZdjX9EtOFf&
client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&
client_secret=hDBmMRhz7eJRsM9Z2q1oFBSe&
redirect_uri=http://localhost/oauth2callback&
grant_type=authorization_code
Run Code Online (Sandbox Code Playgroud)
我试过这样的事情:
headers = {'Content-Type': 'application/x-www-form-urlencoded code=4/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&client_id=xxxxxxxxxxx.apps.googleusercontent.com&client_secret=xxxxxxxxxxxxxxxxx&redirect_uri=http://127.0.0.1:8000/information/youtube/&grant_type=authorization_code'}
r = requests.post(url, headers)
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
<Response [411]>
u'<!DOCTYPE html>\n<html lang=en>\n <meta charset=utf-8>\n <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">\n <title>Error 411 (Length Required)!!1</title>\n <style>\n *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}\n </style>\n <a href=//www.google.com/><img src=//www.google.com/images/errors/logo_sm.gif alt=Google></a>\n <p><b>411.</b> <ins>That\u2019s an error.</ins>\n <p>POST requests require a <code>Content-length</code> header. <ins>That\u2019s …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Google Api客户端代码撤消令牌.
我的代码看起来像这样:
$.get("https://accounts.google.com/o/oauth2/revoke?token=" + accessToken, function () {
window.location.reload();
});
Run Code Online (Sandbox Code Playgroud)
我收到以下错误?
XMLHttpRequest无法加载 https://accounts.google.com/o/oauth2/revoke?token=tokenishere来自Access-Control-Allow-Origin不允许来源 http://balblabla.com.
我正在尝试构建一个视频协作平台.我希望以这样的方式设计它,即有一个API,我的网络应用程序就像一个"第三方"应用程序.
我认为它的工作方式有三个主要组成部分..
我希望能够对"项目"等资源进行经过身份验证的请求
截至目前,我想前端应用程序与Rails应用程序通信以获得经过身份验证的请求,然后前端应用程序使用该经过身份验证的请求来调用API.
我对这个架构有几个问题.
我只是问这些问题,因为OAuth看起来是标准的,我只能通过验证第三方应用来访问另一个应用中的资源.
我想我主要是寻找一些指导,因为我可以构建应用程序,我只是没有安全专家.谢谢大家的帮助.
当我尝试从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 the Request Token...");
Token requestToken = service.getRequestToken();
System.out.println("Got the Request Token!");
System.out.println();
// Obtain the Authorization URL
System.out.println("Fetching the Authorization URL...");
String authorizationUrl = service.getAuthorizationUrl(requestToken);
System.out.println("Got …Run Code Online (Sandbox Code Playgroud) oauth ×10
api ×2
django ×2
python ×2
.net ×1
faraday ×1
google-api ×1
java ×1
javascript ×1
jquery ×1
json ×1
magento ×1
oauth-2.0 ×1
ruby ×1
showdialog ×1
twitter ×1
vb.net ×1
vimeo ×1
youtube ×1
youtube-api ×1