我在AngularJS上使用omniauth-facebook并且CORS无法正常工作.
我的omniauth.rb是
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook,"xxxxx", "xxxxx",
:scope => 'email,user_birthday,read_stream', :display => 'popup'
end
Run Code Online (Sandbox Code Playgroud)
如果我将它用作rails应用程序和请求,一切正常.但是当我尝试通过Angular JS调用'http:\ localhost:3000\users\auth\facebook"时
$http.get('/users/auth/facebook').success(function(data, status, headers, config) {
console.log("back in success");
}).
error(function(data, status, headers, config) {
});
}
Run Code Online (Sandbox Code Playgroud)
我在JS控制台中看到以下错误
XMLHttpRequest无法加载 https://www.facebook.com/dialog/oauth?client_id=xxxx&display=popup ... thday%2Cread_stream&state = 3352c1924bdbc9277f7b1070c38d67acf79b529f198323cb.请求的资源上不存在"Access-Control-Allow-Origin"标头.
'http://localhost:3000'因此不允许原点访问.
(该控制台中的网址未完全显示)
我添加了以下行
config.middleware.insert_before Warden::Manager, Rack::Cors
Run Code Online (Sandbox Code Playgroud)
但这也行不通.
什么是最好的方式或如何覆盖OmniAuth的标头?
我正在使用Angularjs和gem devise,omniauth-facebook
我有一个界面
public interface ParentService{}
Run Code Online (Sandbox Code Playgroud)
和两个实现类
@Service("child1service")
public class Child1 implements ParentService{}
@Service("child2service")
public class Child2 implements ParentService{}
Run Code Online (Sandbox Code Playgroud)
现在我的控制器
public class ServeChild1Controller extendds AbstractController{
@Autowired
public ServeChild1Controller(@Qualifier("child1service") ParentService child1service){
super(child1service)
}
Run Code Online (Sandbox Code Playgroud)
同样有ServeChild2Controller ..
因此,当我运行时,我得到以下错误
ServeChild1Controller的错误:没有定义[com.service.ParentService]类型的唯一bean:期望的单个匹配bean但找到2 child1service,child2service
我试图阅读更多关于这些注释但无法解决它..任何指针将有所帮助谢谢
加载驱动程序有两种方法:
Class.forName()
DriverManager.registerDriver()
方法1内部也调用DriverManager.registerDriver,方法1是首选方法.
但为什么?是否存在任何细微差别或性能等更好?
任何意见都表示赞赏..
嗨,我有一个要求,即A人可以看到B人的日历,并检查某个特定日期人B的时间,并通过点击可用的时段预约.就像是;
3月21日星期一:
上午9点至10点 - 不可用
10-11 - 可用
11-12 - 可用
12-1 - 不可用
..
我尝试了event_calendar插件,但它只提供日期而不是每天的时间段.Rails是否有任何插件?
谢谢
我的控制器层用spring oauth2包裹.我正在编写集成测试来测试对控制器的api调用,所以我决定使用RestTemplate.
以下是我通过curl使用的命令:
curl -v --cookie cookies.txt --cookie-jar cookies.txt "http://localhost:8080/oauth/token?client_id=my-trusted-client&grant_type=password&scope=trust&username=xxxx&password=xxxxxx"
Run Code Online (Sandbox Code Playgroud)
这将返回一个访问令牌,我用它来调用api:
curl -v -H "Authorization: Bearer Access toekn value" "http://localhost:8080/profile/1.json"
Run Code Online (Sandbox Code Playgroud)
在使用时RestTemplate,我能够获得访问令牌,但现在我想传递此令牌来进行api调用:
DefaultHttpClient client = new DefaultHttpClient();
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization: Bearer", accessToken);
System.out.println(accessToken);
HttpEntity<String> entity = new HttpEntity<String>(headers);
System.out.println(restTemplate.exchange("http://localhost:8080/xxxx",HttpMethod.GET,entity,Object.class));
Run Code Online (Sandbox Code Playgroud)
但是,我收到此错误:
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:75)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:377)
at com.gogii.service.SKUService.testGetAllSKU(SKUService.java:20)
Run Code Online (Sandbox Code Playgroud)
我们如何使用经过身份验证的呼叫RestTemplate?
这是一个基本问题 - 当加载spring bean时,如果我有一个构造函数和setter,哪个将首先被调用?
谢谢
我有一个带声明的优先级队列
priority_queue<<Node>,vector<Node>,myComp> openQ
Run Code Online (Sandbox Code Playgroud)
我正在插入节点对象.但有时我必须从中删除元素.(不要删除顶部元素)
目前要删除它我弹出元素并将其放入数组.如果需要最顶层的元素,那么期望它推送数组中的其他元素.
这就像线性搜索和删除.我知道它效率不高,我正在寻找更好的方法
我正在做我的学术项目,在构建和测试时,我已经放了许多println()语句.
但是,当我不得不提交所有打印时,不应该显示.
我可以实现像侦听器这样的东西,当试图执行System.out时会调用它并阻止它显示.我不知道这个想法有多可行,但只是想知道它是否可能.我知道我本来可以使用日志文件或写入文件但是如果我必须禁用SOP,我只能想到一个想法我怎么能这样做..
谢谢
这是我在couchbase的第一次尝试.我的json doc看起来像这样:
{
"member_id": "12345",
"devices": [
{
"device_id": "1",
"hashes": [
"h1",
"h2",
"h3",
"h4"
]
},
{
"device_id": "2",
"hashes": [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"h7"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想创建一个视图,它告诉我给定哈希的所有member_ids.
像这样的东西:
h1["12345","233","2323"] //233,2323 are other member id
h2["12345"]
Run Code Online (Sandbox Code Playgroud)
本member_id应在集合中出现一次.
我写了一个地图功能
function (doc, meta) {
for(i=0;i< doc.devices.length;i++)
{
for(j=0;j< doc.devices[i].hashes.length;j++) {
emit(doc.devices[i].hashes[j],null)
}
}
}
Run Code Online (Sandbox Code Playgroud)
这回来了
h1 "12345"
h1 "12345"
h2 "12345"
h1 "233"
Run Code Online (Sandbox Code Playgroud)
但是我无法从这里前进.我该如何更改地图功能以减少结果?
我想在aws上传图片.
class Asset < ActiveRecord::Base
belongs_to :post
attr_accessible :image
has_attached_file :image, :styles => { :medium => "640x480>",
:thumb => "100x100#"},
:storage => :s3,
:s3_credentials => "#{Rails.root}/config/s3.yml",
:path => ":attachment/:id/:style.:extension",
:bucket => 'yourbucket'
end
Run Code Online (Sandbox Code Playgroud)
s3.yml
development:
access_key_id: xxxxxxxx
secret_code: xxxxx
Run Code Online (Sandbox Code Playgroud)
我收到了一条消息
AWS::Errors::MissingCredentialsError in PostsController#create
Missing Credentials.
Unable to find AWS credentials. You can configure your AWS credentials
a few different ways:
* Call AWS.config with :access_key_id and :secret_access_key
* Export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to ENV
* On EC2 you can run …Run Code Online (Sandbox Code Playgroud)