为什么在使用Ruby gem'fusion_tables'创建Fusion Table时出现403错误? [英] Why am I getting a 403 error when creating a Fusion Table using the Ruby gem 'fusion_tables'?

查看:59
本文介绍了为什么在使用Ruby gem'fusion_tables'创建Fusion Table时出现403错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,根据'fusion_tables'gem文档 .显然,我不会在此代码中发布我的用户名和密码.

Here's my code, as per the 'fusion_tables' gem documentation. Obviously, I don't post my username and password in this code.

require 'fusion_tables'

@ft = GData::Client::FusionTables.new      
@ft.clientlogin(my_google_account_name, my_google_account_password)

# Creating a new table
columns = [
    {
        :name=>"column_1",
        :type=>'string'
    }, 
    {
        :name=>"column_2",
        :type=>'number'
    }
]

new_table = @ft.create_table "Ruby table",columns

# Inserting rows
data = [
    {
    "column_1"=>"This is a string",
    "column_2"=>100
    }
]

new_table.insert data

运行它时,出现此错误:

When I run it, I get this error:

<HEAD>
<TITLE>User does not have permission to view the underlying data</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>User does not have permission to view the underlying data</H1>
<H2>Error 403</H2>
</BODY>
</HTML>

如何解决此问题?

推荐答案

宝石中的create_table method看起来有些过时.

Looks like create_table method in the gem is a bit outdated.

我尝试了上面的示例,并且fusion_tables gem repo .两者都在调用create_table方法的行上抛出Error 403 User does not have permission to view the underlying data错误消息.

I tried the example above, and the boris_bikes example provided in the fusion_tables gem repo. Both throw the Error 403 User does not have permission to view the underlying data error message on the line invoking create_table method.

在上面的示例中,引发此错误的行是:

In the above example, the line throwing this error is:

new_table = @ft.create_table "Ruby table",columns

尽管创建了"Ruby_table"融合表. (注意:fusion_table宝石

The "Ruby_table" fusion table though is created. ( NOTE: The fusion_table gem sanitizes the table name, i.e. it substitutes the spaces in the given name with an underscore. )

最近,最有可能Google Fusion table API对该宝石进行了一些更改.我已经在存储库上打开了一个新期刊;希望开发人员会尽快对此做出回应. (或者,如果时间允许,我会进行深入研究,找出原因,然后提交补丁)

Most likely the Google Fusion table API has changed a bit on this gem in recent times. I have opened a new issue on the repo; hopefully the developers will respond to it soon. (Or if time permit, I will dig into it, figure out the reasons, and submit a patch)

就目前而言,自创建表以来,我建议忽略该错误并继续前进.

For now, I would suggest ignoring the error and continuing forward since the table is created.

运行new_table = @ft.create_table "Ruby table",columns行之后,继续执行以下步骤:

After running the new_table = @ft.create_table "Ruby table",columns line, continue with the following steps:

tables = @ft.show_tables
new_table  = tables.select{|t| t.name == "Ruby_table" }.first

# Inserting rows
data = [ 
 { 
    "column_1"=>"This is a string",
    "column_2"=>100
  }
]

new_table.insert data

这样,您应该会在Fusion Table中看到该行.

With that you should see the line show up in the Fusion Table.

在我的一个生产应用中,我们手动创建了所需的Fusion Tables-将其与现有的Data表(目前尚不支持API)合并,然后使用truncate& insert方法来更新Fusion表数据.因此,对于我们来说,无法以编程方式创建Fusion Table并不是一个大问题.

On one of my Production Apps, we manually created the required Fusion Tables - merged it with existing Data tables (for which there is no API support as of now), and then use the truncate & insert methods to update the Fusion table data. So not being able to create a Fusion Table programmatically didn't come up as a big issue for us there.

这篇关于为什么在使用Ruby gem'fusion_tables'创建Fusion Table时出现403错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆