Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby google oauth命令行示例中的用户id是什么?_Ruby_Oauth 2.0_Youtube Api_Google Oauth - Fatal编程技术网

Ruby google oauth命令行示例中的用户id是什么?

Ruby google oauth命令行示例中的用户id是什么?,ruby,oauth-2.0,youtube-api,google-oauth,Ruby,Oauth 2.0,Youtube Api,Google Oauth,在本例中,用户id应该来自哪里 使用下面的命令行示例: 我只是通过删除“/path/to/”更改了示例,并且在我的工作目录中有一个client_secrets.json require 'googleauth' require 'googleauth/stores/file_token_store' OOB_URI = 'urn:ietf:wg:oauth:2.0:oob' scope = 'https://www.googleapis.com/auth/drive' client_id

在本例中,用户id应该来自哪里

使用下面的命令行示例:

我只是通过删除“/path/to/”更改了示例,并且在我的工作目录中有一个client_secrets.json

require 'googleauth'
require 'googleauth/stores/file_token_store'

OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'

scope = 'https://www.googleapis.com/auth/drive'
client_id = Google::Auth::ClientId.from_file('client_secrets.json')
token_store = Google::Auth::Stores::FileTokenStore.new(
  :file => 'tokens.yaml')
authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)

credentials = authorizer.get_credentials(user_id)
if credentials.nil?
  url = authorizer.get_authorization_url(base_url: OOB_URI )
  puts "Open #{url} in your browser and enter the resulting code:"
  code = gets
  credentials = authorizer.get_and_store_credentials_from_code(
    user_id: user_id, code: code, base_url: OOB_URI)
end
运行此代码将打印出一个url以插入我的浏览器。url会将我带到同意屏幕。在我接受之后,我会得到一个代码,可以插回终端

然后我得到一个错误:

NameError: undefined local variable or method `user_id' for main:Object
。。。因为显然用户id没有定义,但是我从哪里得到它呢


或者,是否有更好、更新的,或者更好的文档化oauth 2.0库,我应该将Ruby与所有youtube API结合使用?

用户id应该是点击链接的人的电子邮件地址。

用户id应该是点击链接的人的电子邮件地址。

对于任何其他对此感到疑惑的人,我相信您可以安全地设置 用户\u id='default'


如果用户被重定向到授权人,这将向用户显示一个“选择帐户”对话框。如果其他人想知道我相信您可以安全地设置 用户\u id='default'

如果用户被重定向到授权人,这将向用户显示“选择帐户”对话框。get_authorization_url