- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试将数据从 Rails 应用程序导出到 Google 日历,但登录后我无法在 request.env 中找到“omniauth.auth”。
我使用 Rails 4.0.4 和 Ruby 2.0.0p481
我的 gem 文件
gem 'google-api-client', '~> 0.7.1', :require => 'google/api_client'
gem 'omniauth', '~> 1.2.1'
gem 'omniauth-google-oauth2', '~> 0.2.4'
omniauth.rb
OmniAuth.config.full_host = "http://localhost:3000"
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2, 'MY_GOOGLE_CLIENT_ID', 'MY_GOOGLE_SECRET', { :access_type => 'offline', :prompt => 'consent', :approval_prompt => 'force', :scope => 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar', :redirect_uri => 'http://localhost:3000/auth/google-oauth2/callback', }
end
Controller
class GoogleAuthController < ApplicationController
def create
@auth = request.env['omniauth.auth'] #here not found 'omniath.auth' and @auth is nil
if @auth.nil?
flash[:danger] = "Error during connection with Google API."
redirect_to holidays_path
else
@token = @auth['credential']['token']
#another action after login
end
end
end
路线
match "/auth/:provider/callback", to: "google_auth#create", via: 'get'
Google apis (I cannot add a image, )
如果您能帮助解决这个问题,我将非常感激。
编辑:
请求.env
{"GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/auth/google-oauth2/callback", "QUERY_STRING"=>"state=fc29151421330cb904b4c4984bdd52e21a53d98531389b74&code=4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", "REMOTE_ADDR"=>"127.0.0.1", "REMOTE_HOST"=>"127.0.0.1", "REQUEST_METHOD"=>"GET", "REQUEST_URI"=>"http://localhost:3000/auth/google-oauth2/callback?state=fc29151421330cb904b4c4984bdd52e21a53d98531389b74&code=4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/2.0.0/2014-05-08)", "HTTP_HOST"=>"localhost:3000", "HTTP_USER_AGENT"=>"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0", "HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "HTTP_ACCEPT_LANGUAGE"=>"en-gb,pl;q=0.5", "HTTP_ACCEPT_ENCODING"=>"gzip, deflate", "HTTP_DNT"=>"1", "HTTP_COOKIE"=>"csrftoken=SlECAmtvbK9jqvqpS6D8nf2YMNdgGvnQ; holidays_view=list; logged_to_google=false; remember_token=EjYlew0u1zVPf21OfDA5hw; _HolidayManager_session=Zm43QVVrd2dKSkFLbnUvZnZLYzlhTVZ6QVNISDErYU5wVzg4ek90dFFoVXVZUHlpb1c3Q2NldGV1R05IellhbHNTYS92TFlLK1dMK3drR3p2bldXejVlbTJGaktnTXNyZWkzdnVJd05PQ3dyb0R0bndjeFV5S01CL1hybFVITzZRM1lqZWxGa1FFQnJ0ektWZUpwNlV2MnNnU3p2OVR2WnE0ME11aDNJZDNLekZSNm85MU9ZdWhZWVlGL0Y3dGdTS0E2NjI4Zk5EQ3Y5WHI1MWRUaC9JSEFwYjNpbkNtMmZ5RTdRWTF5ak1kQ2E5T1hwcFMzczRYZHpjYkxKNldxdzJDZDhreFNqWW9ySGhnNU02dmNwSzlQaUJDbVQrN2FhcFpQYzNHWWQ4OVp2VlVFTFAzQ1hLUWZ2aEJpUkg0Y3g0citJK3pMcU1VdUpNOEJxWTFhRGtMVEdhQVEyUGhxMzRmNytVUEczTmw3SEJQdk94dGZtUysvYVI1M3pjUTFlMmYxVGdFL0UrME5nTXNWblU5V0gvZzViMEJKSUhtbmRlZUo4RnB6VWkzQlBMaHlUYUZhY2xBZTg0TUxtdW44Zy0teUVlY1Y5bXNDRi9XdGxPWWIyNmsyQT09--7c4d0f8a5be4c25d7fbc8f9922425f267d7c9c10", "HTTP_CONNECTION"=>"keep-alive", "HTTP_CACHE_CONTROL"=>"max-age=0", "rack.version"=>[1, 2], "rack.input"=>#<StringIO:0x007fd805127750>, "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "HTTP_VERSION"=>"HTTP/1.1", "REQUEST_PATH"=>"/auth/google-oauth2/callback", "ORIGINAL_FULLPATH"=>"/auth/google-oauth2/callback?state=fc29151421330cb904b4c4984bdd52e21a53d98531389b74&code=4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", "ORIGINAL_SCRIPT_NAME"=>"", "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x00000002d54308>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"d4b9400cc11ac95836a873c775f9597d9d6428bb4a3d82e3723da38bf04914735397b697d45dbeb6fa4b1a8719c6f87b2e333510d316e1a0f4b1ad40eecf0f8a", "action_dispatch.show_exceptions"=>true, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<Logger:0x000000012f8658 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x000000012f83d8 @datetime_format=nil>, @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x000000012ff2f0 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x000000012fcfc8 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x000000012fd810 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x000000012fee40>>>>, "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x0000000427c168 @filters=[#<Proc:0x0000000428bac8@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.4/lib/rails/backtrace_cleaner.rb:10>, #<Proc:0x0000000428baa0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.4/lib/rails/backtrace_cleaner.rb:11>, #<Proc:0x0000000428ba78@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.4/lib/rails/backtrace_cleaner.rb:12>, #<Proc:0x000000042896b0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.4/lib/rails/backtrace_cleaner.rb:24>], @silencers=[#<Proc:0x00000004289570@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/railties-4.0.4/lib/rails/backtrace_cleaner.rb:15>]>, "action_dispatch.key_generator"=>#<ActiveSupport::CachingKeyGenerator:0x000000042893e0 @key_generator=#<ActiveSupport::KeyGenerator:0x00000004289408 @secret="d4b9400cc11ac95836a873c775f9597d9d6428bb4a3d82e3723da38bf04914735397b697d45dbeb6fa4b1a8719c6f87b2e333510d316e1a0f4b1ad40eecf0f8a", @iterations=1000>, @cache_keys=#<ThreadSafe::Cache:0x000000042893b8 @backend={"encrypted cookie64"=>"+&\x1E\x8D7h\x00l_3Z\x02\xCEYU\xE5\xD1\xAC-\xD7z\xE3\xF2\xD8\xA6Pn\x96\x84Cx\xDE\x98Z\xC5\x80js\xF7\xF8q\x04s\b\xCFf\x96v\x98~\xED\x9C\x11\xDE\xC1\xD8\x1Dz\x1DS\x12\xA4\xDF<", "signed encrypted cookie64"=>"\x86\xD9\xEC\xFFu\xE9\xA2\xC7z\xD8\x990\xDE+#s\xC1\x1E$\x1E;Jd\x8B\xA2\x9A\xB9\x05>\x01\xF5\xB6\x0E\xC0\x10\xD9\xD5\xF7\xBA[$\xC9m\xE65<}D\xA0b\xE7\xE8y\xCA6\x1F\x02\xA3S\x1F[\xFEk\xD1"}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "ROUTES_23765380_SCRIPT_NAME"=>"", "action_dispatch.request_id"=>"bf2e900d-3cc9-4a21-88cf-12a2fdcbcc09", "action_dispatch.remote_ip"=>#<ActionDispatch::RemoteIp::GetIp:0x007fd805124d20 @env={...}, @check_ip=true, @proxies=/
^127\.0\.0\.1$ | # localhost IPv4
^::1$ | # localhost IPv6
^fc00: | # private IPv6 range fc00
^10\. | # private IPv4 range 10.x.x.x
^172\.(1[6-9]|2[0-9]|3[0-1])\.| # private IPv4 range 172.16.0.0 .. 172.31.255.255
^192\.168\. # private IPv4 range 192.168.x.x
/x>, "rack.session"=>#<ActionDispatch::Request::Session:0x007fd7f813b2d0 @by=#<ActionDispatch::Session::CookieStore:0x00000003db62f0 @app=#<ActionDispatch::Flash:0x00000003db6390 @app=#<ActionDispatch::ParamsParser:0x00000003db67a0 @app=#<Rack::Head:0x00000003db67c8 @app=#<Rack::ConditionalGet:0x00000003db67f0 @app=#<Rack::ETag:0x00000003db6818 @app=#<OmniAuth::Builder:0x00000003db7df8 @options=nil, @run=#<ActionDispatch::Routing::RouteSet:0x00000002d54308>, @map=nil, @use=[#<Proc:0x00000003db7420@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.5.2/lib/rack/builder.rb:86>, #<Proc:0x00000003db6890@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.5.2/lib/rack/builder.rb:86>]>, @cache_control="max-age=0, private, must-revalidate", @no_cache_control="no-cache">>>, @parsers={#<Mime::Type:0x00000002c92e60 @synonyms=["text/x-json", "application/jsonrequest"], @symbol=:json, @string="application/json">=>:json}>>, @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false}, @key="_HolidayManager_session", @cookie_only=true>, @env={...}, @delegate={"session_id"=>"465d10f227d1b1033088b17f3aa77cb3", "_csrf_token"=>"SghTPesnhyoSKhA2yFhM4d20/KjqIPixcFUSCpn5jX4=", "omniauth.params"=>{}, "omniauth.state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74", "flash"=>{"discard"=>[:danger], "flashes"=>{:danger=>"Error during connection with Google API."}}}, @loaded=true, @exists=true>, "rack.session.options"=>#<ActionDispatch::Request::Session::Options:0x007fd7f813b280 @by=#<ActionDispatch::Session::CookieStore:0x00000003db62f0 @app=#<ActionDispatch::Flash:0x00000003db6390 @app=#<ActionDispatch::ParamsParser:0x00000003db67a0 @app=#<Rack::Head:0x00000003db67c8 @app=#<Rack::ConditionalGet:0x00000003db67f0 @app=#<Rack::ETag:0x00000003db6818 @app=#<OmniAuth::Builder:0x00000003db7df8 @options=nil, @run=#<ActionDispatch::Routing::RouteSet:0x00000002d54308>, @map=nil, @use=[#<Proc:0x00000003db7420@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.5.2/lib/rack/builder.rb:86>, #<Proc:0x00000003db6890@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/rack-1.5.2/lib/rack/builder.rb:86>]>, @cache_control="max-age=0, private, must-revalidate", @no_cache_control="no-cache">>>, @parsers={#<Mime::Type:0x00000002c92e60 @synonyms=["text/x-json", "application/jsonrequest"], @symbol=:json, @string="application/json">=>:json}>>, @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false}, @key="_HolidayManager_session", @cookie_only=true>, @env={...}, @delegate={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false, :id=>"465d10f227d1b1033088b17f3aa77cb3"}>, "action_dispatch.request.path_parameters"=>{:controller=>"google_auth", :action=>"create", :provider=>"google-oauth2"}, "action_controller.instance"=>#<GoogleAuthController:0x007fd7f813db70 @_routes=nil, @_action_has_layout=true, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_request=#<ActionDispatch::Request:0x007fd7f813da58 @env={...}, @symbolized_path_params=nil, @filtered_parameters={"state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74", "code"=>"4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", "controller"=>"google_auth", "action"=>"create", "provider"=>"google-oauth2"}, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method="GET", @request_method="GET", @remote_ip=nil, @original_fullpath=nil, @fullpath="/auth/google-oauth2/callback?state=fc29151421330cb904b4c4984bdd52e21a53d98531389b74&code=4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", @ip=nil, @uuid=nil>, @_response=#<ActionDispatch::Response:0x007fd7f813da30 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fd7f813d990>, @stream=#<ActionDispatch::Response::Buffer:0x007fd7f813d8f0 @response=#<ActionDispatch::Response:0x007fd7f813da30 ...>, @buf=[], @closed=false>, @header={"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff", "X-UA-Compatible"=>"chrome=1"}, @status=200, @sending_file=false, @blank=false, @cv=#<MonitorMixin::ConditionVariable:0x007fd7f813d8c8 @monitor=#<ActionDispatch::Response:0x007fd7f813da30 ...>, @cond=#<ConditionVariable:0x007fd7f813d8a0 @waiters={}, @waiters_mutex=#<Mutex:0x007fd7f813d850>>>, @committed=false, @content_type=nil, @charset=nil, @cache_control={}, @etag=nil, @request=#<ActionDispatch::Request:0x007fd7f813da58 @env={...}, @symbolized_path_params=nil, @filtered_parameters={"state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74", "code"=>"4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", "controller"=>"google_auth", "action"=>"create", "provider"=>"google-oauth2"}, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method="GET", @request_method="GET", @remote_ip=nil, @original_fullpath=nil, @fullpath="/auth/google-oauth2/callback?state=fc29151421330cb904b4c4984bdd52e21a53d98531389b74&code=4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", @ip=nil, @uuid=nil>>, @_env={...}, @_prefixes=["google_auth", "application"], @_lookup_context=#<ActionView::LookupContext:0x007fd7f813d670 @details_key=nil, @details={:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}, @skip_default_locale=false, @cache=true, @prefixes=["google_auth", "application"], @rendered_format=nil, @view_paths=#<ActionView::PathSet:0x007fd7f813d5f8 @paths=[#<ActionView::OptimizedFileSystemResolver:0x000000040e0bd8 @pattern=":prefix/:action{.:locale,}{.:formats,}{.:handlers,}", @cache=#<ActionView::Resolver::Cache:0x000000040e0bb0 @data=#<ActionView::Resolver::Cache::SmallCache:0x000000040e0b88 @backend={#<ActionView::LookupContext::DetailsKey:0x0000000392d6c0 @hash=-2472005154318598025>=>#<ActionView::Resolver::Cache::SmallCache:0x0000000394bee0 @backend={"create"=>#<ActionView::Resolver::Cache::SmallCache:0x0000000394bbe8 @backend={"google_auth"=>#<ActionView::Resolver::Cache::SmallCache:0x0000000394b8a0 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x0000000394b440 @backend={[]=>[app/views/google_auth/create.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x000000036d35f0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x000000036d33c0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:46 (lambda)>>, "google_auth"=>#<ActionView::Resolver::Cache::SmallCache:0x00000003958bb8 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x00000003961a88 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x00000003963810 @backend={}, @default_proc=nil>}, @default_proc=#<Proc:0x000000036d35f0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x000000036d33c0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:46 (lambda)>>, "application"=>#<ActionView::Resolver::Cache::SmallCache:0x00000003966f60 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x00000003966e70 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x00000003966b78 @backend={[]=>[app/views/layouts/application.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x000000036d35f0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x000000036d33c0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:46 (lambda)>>, "navbar"=>#<ActionView::Resolver::Cache::SmallCache:0x007fd804e326d0 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x007fd804e325e0 @backend={true=>#<ActionView::Resolver::Cache::SmallCache:0x007fd804e324f0 @backend={[]=>[app/views/layouts/_navbar.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x000000036d35f0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x000000036d33c0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:46 (lambda)>>, "footer"=>#<ActionView::Resolver::Cache::SmallCache:0x007fd8050e52d8 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x007fd8050e51e8 @backend={true=>#<ActionView::Resolver::Cache::SmallCache:0x007fd8050e50f8 @backend={[]=>[app/views/layouts/_footer.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x000000036d35f0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x000000036d33c0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:46 (lambda)>>, "index"=>#<ActionView::Resolver::Cache::SmallCache:0x00000004243228 @backend={"holidays"=>#<ActionView::Resolver::Cache::SmallCache:0x00000004243138 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x00000004242fd0 @backend={[]=>[app/views/holidays/index.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x000000036d35f0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x000000036d33c0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:46 (lambda)>>, "holidays"=>#<ActionView::Resolver::Cache::SmallCache:0x00000004241d10 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x00000004241bd0 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x00000004241ab8 @backend={}, @default_proc=nil>}, @default_proc=#<Proc:0x000000036d35f0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:45 (lambda)>>}, @default_proc=#<Proc:0x000000036d33c0@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x000000036d3398@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:47 (lambda)>>}, @default_proc=#<Proc:0x000000036d3348@/home/damian/.rvm/gems/ruby-2.0.0-p481/gems/actionpack-4.0.4/lib/action_view/template/resolver.rb:48 (lambda)>>>, @path="/home/damian/i4b/HolidayManager/branches/googleapis/HolidayManager/app/views">]>>, @_action_name="create", @_response_body=nil, @_config={}, @auth=nil, @result={...}>, "action_dispatch.request.content_type"=>nil, "action_dispatch.request.request_parameters"=>{}, "rack.request.query_string"=>"state=fc29151421330cb904b4c4984bdd52e21a53d98531389b74&code=4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", "rack.request.query_hash"=>{"state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74", "code"=>"4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI"}, "action_dispatch.request.query_parameters"=>{"state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74", "code"=>"4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI"}, "action_dispatch.request.parameters"=>{"state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74", "code"=>"4/mi7TtHWcFpyMeeA-ikQHb6dV5Qki.grzx2bQTFb8dYFZr95uygvVpKDFKjgI", "controller"=>"google_auth", "action"=>"create", "provider"=>"google-oauth2"}, "action_dispatch.request.formats"=>[#<Mime::Type:0x00000002c7e2f8 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html">], "rack.request.cookie_hash"=>{"csrftoken"=>"SlECAmtvbK9jqvqpS6D8nf2YMNdgGvnQ", "holidays_view"=>"list", "logged_to_google"=>"false", "remember_token"=>"EjYlew0u1zVPf21OfDA5hw", "_HolidayManager_session"=>"Zm43QVVrd2dKSkFLbnUvZnZLYzlhTVZ6QVNISDErYU5wVzg4ek90dFFoVXVZUHlpb1c3Q2NldGV1R05IellhbHNTYS92TFlLK1dMK3drR3p2bldXejVlbTJGaktnTXNyZWkzdnVJd05PQ3dyb0R0bndjeFV5S01CL1hybFVITzZRM1lqZWxGa1FFQnJ0ektWZUpwNlV2MnNnU3p2OVR2WnE0ME11aDNJZDNLekZSNm85MU9ZdWhZWVlGL0Y3dGdTS0E2NjI4Zk5EQ3Y5WHI1MWRUaC9JSEFwYjNpbkNtMmZ5RTdRWTF5ak1kQ2E5T1hwcFMzczRYZHpjYkxKNldxdzJDZDhreFNqWW9ySGhnNU02dmNwSzlQaUJDbVQrN2FhcFpQYzNHWWQ4OVp2VlVFTFAzQ1hLUWZ2aEJpUkg0Y3g0citJK3pMcU1VdUpNOEJxWTFhRGtMVEdhQVEyUGhxMzRmNytVUEczTmw3SEJQdk94dGZtUysvYVI1M3pjUTFlMmYxVGdFL0UrME5nTXNWblU5V0gvZzViMEJKSUhtbmRlZUo4RnB6VWkzQlBMaHlUYUZhY2xBZTg0TUxtdW44Zy0teUVlY1Y5bXNDRi9XdGxPWWIyNmsyQT09--7c4d0f8a5be4c25d7fbc8f9922425f267d7c9c10"}, "rack.request.cookie_string"=>"csrftoken=SlECAmtvbK9jqvqpS6D8nf2YMNdgGvnQ; holidays_view=list; logged_to_google=false; remember_token=EjYlew0u1zVPf21OfDA5hw; _HolidayManager_session=Zm43QVVrd2dKSkFLbnUvZnZLYzlhTVZ6QVNISDErYU5wVzg4ek90dFFoVXVZUHlpb1c3Q2NldGV1R05IellhbHNTYS92TFlLK1dMK3drR3p2bldXejVlbTJGaktnTXNyZWkzdnVJd05PQ3dyb0R0bndjeFV5S01CL1hybFVITzZRM1lqZWxGa1FFQnJ0ektWZUpwNlV2MnNnU3p2OVR2WnE0ME11aDNJZDNLekZSNm85MU9ZdWhZWVlGL0Y3dGdTS0E2NjI4Zk5EQ3Y5WHI1MWRUaC9JSEFwYjNpbkNtMmZ5RTdRWTF5ak1kQ2E5T1hwcFMzczRYZHpjYkxKNldxdzJDZDhreFNqWW9ySGhnNU02dmNwSzlQaUJDbVQrN2FhcFpQYzNHWWQ4OVp2VlVFTFAzQ1hLUWZ2aEJpUkg0Y3g0citJK3pMcU1VdUpNOEJxWTFhRGtMVEdhQVEyUGhxMzRmNytVUEczTmw3SEJQdk94dGZtUysvYVI1M3pjUTFlMmYxVGdFL0UrME5nTXNWblU5V0gvZzViMEJKSUhtbmRlZUo4RnB6VWkzQlBMaHlUYUZhY2xBZTg0TUxtdW44Zy0teUVlY1Y5bXNDRi9XdGxPWWIyNmsyQT09--7c4d0f8a5be4c25d7fbc8f9922425f267d7c9c10", "action_dispatch.cookies"=>#<ActionDispatch::Cookies::CookieJar:0x007fd7ec19a638 @key_generator=#<ActiveSupport::CachingKeyGenerator:0x000000042893e0 @key_generator=#<ActiveSupport::KeyGenerator:0x00000004289408 @secret="d4b9400cc11ac95836a873c775f9597d9d6428bb4a3d82e3723da38bf04914735397b697d45dbeb6fa4b1a8719c6f87b2e333510d316e1a0f4b1ad40eecf0f8a", @iterations=1000>, @cache_keys=#<ThreadSafe::Cache:0x000000042893b8 @backend={"encrypted cookie64"=>"+&\x1E\x8D7h\x00l_3Z\x02\xCEYU\xE5\xD1\xAC-\xD7z\xE3\xF2\xD8\xA6Pn\x96\x84Cx\xDE\x98Z\xC5\x80js\xF7\xF8q\x04s\b\xCFf\x96v\x98~\xED\x9C\x11\xDE\xC1\xD8\x1Dz\x1DS\x12\xA4\xDF<", "signed encrypted cookie64"=>"\x86\xD9\xEC\xFFu\xE9\xA2\xC7z\xD8\x990\xDE+#s\xC1\x1E$\x1E;Jd\x8B\xA2\x9A\xB9\x05>\x01\xF5\xB6\x0E\xC0\x10\xD9\xD5\xF7\xBA[$\xC9m\xE65<}D\xA0b\xE7\xE8y\xCA6\x1F\x02\xA3S\x1F[\xFEk\xD1"}, @default_proc=nil>>, @set_cookies={"request_method"=>{:value=>"GET", :path=>"/"}}, @delete_cookies={}, @host="localhost", @secure=false, @options={:signed_cookie_salt=>"signed cookie", :encrypted_cookie_salt=>"encrypted cookie", :encrypted_signed_cookie_salt=>"signed encrypted cookie", :secret_token=>nil, :secret_key_base=>"d4b9400cc11ac95836a873c775f9597d9d6428bb4a3d82e3723da38bf04914735397b697d45dbeb6fa4b1a8719c6f87b2e333510d316e1a0f4b1ad40eecf0f8a", :upgrade_legacy_signed_cookies=>false}, @cookies={"csrftoken"=>"SlECAmtvbK9jqvqpS6D8nf2YMNdgGvnQ", "holidays_view"=>"list", "logged_to_google"=>"false", "remember_token"=>"EjYlew0u1zVPf21OfDA5hw", "_HolidayManager_session"=>"Zm43QVVrd2dKSkFLbnUvZnZLYzlhTVZ6QVNISDErYU5wVzg4ek90dFFoVXVZUHlpb1c3Q2NldGV1R05IellhbHNTYS92TFlLK1dMK3drR3p2bldXejVlbTJGaktnTXNyZWkzdnVJd05PQ3dyb0R0bndjeFV5S01CL1hybFVITzZRM1lqZWxGa1FFQnJ0ektWZUpwNlV2MnNnU3p2OVR2WnE0ME11aDNJZDNLekZSNm85MU9ZdWhZWVlGL0Y3dGdTS0E2NjI4Zk5EQ3Y5WHI1MWRUaC9JSEFwYjNpbkNtMmZ5RTdRWTF5ak1kQ2E5T1hwcFMzczRYZHpjYkxKNldxdzJDZDhreFNqWW9ySGhnNU02dmNwSzlQaUJDbVQrN2FhcFpQYzNHWWQ4OVp2VlVFTFAzQ1hLUWZ2aEJpUkg0Y3g0citJK3pMcU1VdUpNOEJxWTFhRGtMVEdhQVEyUGhxMzRmNytVUEczTmw3SEJQdk94dGZtUysvYVI1M3pjUTFlMmYxVGdFL0UrME5nTXNWblU5V0gvZzViMEJKSUhtbmRlZUo4RnB6VWkzQlBMaHlUYUZhY2xBZTg0TUxtdW44Zy0teUVlY1Y5bXNDRi9XdGxPWWIyNmsyQT09--7c4d0f8a5be4c25d7fbc8f9922425f267d7c9c10", "request_method"=>"GET"}, @encrypted=#<ActionDispatch::Cookies::EncryptedCookieJar:0x007fd7ec198e00 @parent_jar=#<ActionDispatch::Cookies::CookieJar:0x007fd7ec19a638 ...>, @options={:signed_cookie_salt=>"signed cookie", :encrypted_cookie_salt=>"encrypted cookie", :encrypted_signed_cookie_salt=>"signed encrypted cookie", :secret_token=>nil, :secret_key_base=>"d4b9400cc11ac95836a873c775f9597d9d6428bb4a3d82e3723da38bf04914735397b697d45dbeb6fa4b1a8719c6f87b2e333510d316e1a0f4b1ad40eecf0f8a", :upgrade_legacy_signed_cookies=>false}, @encryptor=#<ActiveSupport::MessageEncryptor:0x007fd7ec198cc0 @secret="+&\x1E\x8D7h\x00l_3Z\x02\xCEYU\xE5\xD1\xAC-\xD7z\xE3\xF2\xD8\xA6Pn\x96\x84Cx\xDE\x98Z\xC5\x80js\xF7\xF8q\x04s\b\xCFf\x96v\x98~\xED\x9C\x11\xDE\xC1\xD8\x1Dz\x1DS\x12\xA4\xDF<", @sign_secret="\x86\xD9\xEC\xFFu\xE9\xA2\xC7z\xD8\x990\xDE+#s\xC1\x1E$\x1E;Jd\x8B\xA2\x9A\xB9\x05>\x01\xF5\xB6\x0E\xC0\x10\xD9\xD5\xF7\xBA[$\xC9m\xE65<}D\xA0b\xE7\xE8y\xCA6\x1F\x02\xA3S\x1F[\xFEk\xD1", @cipher="aes-256-cbc", @verifier=#<ActiveSupport::MessageVerifier:0x007fd7ec198bd0 @secret="\x86\xD9\xEC\xFFu\xE9\xA2\xC7z\xD8\x990\xDE+#s\xC1\x1E$\x1E;Jd\x8B\xA2\x9A\xB9\x05>\x01\xF5\xB6\x0E\xC0\x10\xD9\xD5\xF7\xBA[$\xC9m\xE65<}D\xA0b\xE7\xE8y\xCA6\x1F\x02\xA3S\x1F[\xFEk\xD1", @digest="SHA1", @serializer=ActiveSupport::MessageEncryptor::NullSerializer>, @serializer=Marshal>>, @signed_or_encrypted=#<ActionDispatch::Cookies::EncryptedCookieJar:0x007fd7ec198e00 @parent_jar=#<ActionDispatch::Cookies::CookieJar:0x007fd7ec19a638 ...>, @options={:signed_cookie_salt=>"signed cookie", :encrypted_cookie_salt=>"encrypted cookie", :encrypted_signed_cookie_salt=>"signed encrypted cookie", :secret_token=>nil, :secret_key_base=>"d4b9400cc11ac95836a873c775f9597d9d6428bb4a3d82e3723da38bf04914735397b697d45dbeb6fa4b1a8719c6f87b2e333510d316e1a0f4b1ad40eecf0f8a", :upgrade_legacy_signed_cookies=>false}, @encryptor=#<ActiveSupport::MessageEncryptor:0x007fd7ec198cc0 @secret="+&\x1E\x8D7h\x00l_3Z\x02\xCEYU\xE5\xD1\xAC-\xD7z\xE3\xF2\xD8\xA6Pn\x96\x84Cx\xDE\x98Z\xC5\x80js\xF7\xF8q\x04s\b\xCFf\x96v\x98~\xED\x9C\x11\xDE\xC1\xD8\x1Dz\x1DS\x12\xA4\xDF<", @sign_secret="\x86\xD9\xEC\xFFu\xE9\xA2\xC7z\xD8\x990\xDE+#s\xC1\x1E$\x1E;Jd\x8B\xA2\x9A\xB9\x05>\x01\xF5\xB6\x0E\xC0\x10\xD9\xD5\xF7\xBA[$\xC9m\xE65<}D\xA0b\xE7\xE8y\xCA6\x1F\x02\xA3S\x1F[\xFEk\xD1", @cipher="aes-256-cbc", @verifier=#<ActiveSupport::MessageVerifier:0x007fd7ec198bd0 @secret="\x86\xD9\xEC\xFFu\xE9\xA2\xC7z\xD8\x990\xDE+#s\xC1\x1E$\x1E;Jd\x8B\xA2\x9A\xB9\x05>\x01\xF5\xB6\x0E\xC0\x10\xD9\xD5\xF7\xBA[$\xC9m\xE65<}D\xA0b\xE7\xE8y\xCA6\x1F\x02\xA3S\x1F[\xFEk\xD1", @digest="SHA1", @serializer=ActiveSupport::MessageEncryptor::NullSerializer>, @serializer=Marshal>>>, "action_dispatch.request.unsigned_session_cookie"=>{"session_id"=>"465d10f227d1b1033088b17f3aa77cb3", "_csrf_token"=>"SghTPesnhyoSKhA2yFhM4d20/KjqIPixcFUSCpn5jX4=", "omniauth.params"=>{}, "omniauth.state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74", "flash"=>{"discard"=>[:danger], "flashes"=>{:danger=>"Error during connection with Google API."}}}}
编辑2:
好的。我定位了问题。当我在omniauth.rb中评论选项时,它记录了我
{ :access_type => 'offline', :prompt => 'consent', :approval_prompt => 'force', :scope => 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/calendar', :redirect_uri => 'http://localhost:3000/auth/google-oauth2/callback', }
最佳答案
查看 request.env
哈希值,没有 omniauth.auth
键 - 有一个 omniauth.state
键...也许这就是你想要的?
env
哈希值的末尾还包含以下内容:
unsigned_session_cookie"=>{
"session_id"=>"465d10f227d1b1033088b17f3aa77cb3",
"_csrf_token"=>"SghTPesnhyoSKhA2yFhM4d20/KjqIPixcFUSCpn5jX4=",
"omniauth.params"=>{},
"omniauth.state"=>"fc29151421330cb904b4c4984bdd52e21a53d98531389b74",
"flash"=>{
"discard"=>[:danger],
"flashes"=>{:danger=>"Error during connection with Google API."}}
}
}
这可能只是连接问题,正如该闪现消息似乎暗示的那样。
关于ruby-on-rails - request.env ['omniauth.auth' ] 在 Ruby on Rails 中为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24694460/
sanitize 是什么意思在 Rails 中是什么意思? 我正在阅读 CanCanCan 的文档.它说: When using strong_parameters or Rails 4+, you
在过去的几个月里,我感觉自己对 Ruby on Rails (RoR) 开发的了解达到了极限。我为大/小客户和 friend /爱好项目开发了大大小小的应用程序。我知道如何开发这些应用程序,但开始感觉
我昨天参加了一个关于扩展 Rails 的聚会,其中一个主题是 Hexagonal Rails。然而,我只做了一年的 Rails,对 MVC 结构非常满意(也许太舒服了),所以我不太了解适配器和消息队列
我使用多个 Rails 应用程序,一些在 Rails 3.2/Ruby 2.0 上,一些在 Rails 2.3/Ruby 1.8.7 上。 他们的共同点是,随着他们的成长和添加更多的依赖项/ gem
这个问题在这里已经有了答案: Using Rails-UJS in JS modules (Rails 6 with webpacker) (5 个答案) 关闭 3 年前。 我正在尝试使用 UJS
我正在开发一个当前使用 Rails 1.2 的 Rails 应用程序,所以我现在离最新的稳定版本(Rails 2.3)还有很长的路要走。 我应该如何进行迁移到更新版本的 Rails 的过程? 我应该一
尝试按照 Ryan Bates Backbone.js 教程构建抽奖应用程序,但我已经遇到了第一段代码的问题。在 application.js 的 init 函数中,他初始化了 Raffler 路由的
我正在使用 Rails 3.2 并且我有一个数据库表,我想在其中找到符合以下条件的所有行: a = true and b = true and ( 0 true, :b =>
我有一个用户类和一个联系人,其中联系人是用户的子类。这两个类都存储在用户表中。 我的联系人可能有也可能没有电子邮件地址,而我的用户需要一个电子邮件地址(我的用户模型定义中有 validates_pre
我正在编写一个教程,我在其中演示了一些 rails 命令。在我的机器上 rails和 script/rails两者都同样有效。有“首选”形式吗?两者中哪一个更普遍? 最佳答案 当您运行 rails 时
我正在寻找有关通过我的应用程序前进的最佳方式的建议,这是我首次开始集成Elasticsearch。我是一名初学者,但是热衷于深入研究,以便原谅任何明显的错误! 我遵循了http://www.sitep
我刚刚用 Rails new 启动了一个新的 Rails 应用程序,将默认数据库设置更改为 PostgresSQL。我用 bin/rails s 启动服务器,结果很奇怪 2016-04-21 05:0
我收到一个参数并希望它是这样的字符串: "abc,efg" 或者像这样的数组 ["abc","efg"] 在第一种情况下,我想将它转换成一个数组,什么是好的方法? 这是我的想法 if params[:
我刚刚用 Rails new 启动了一个新的 Rails 应用程序,将默认数据库设置更改为 PostgresSQL。我用 bin/rails s 启动服务器,结果很奇怪 2016-04-21 05:0
我收到一个参数并希望它是这样的字符串: "abc,efg" 或者像这样的数组 ["abc","efg"] 在第一种情况下,我想将它转换成一个数组,什么是好的方法? 这是我的想法 if params[:
我有 Rails 4,这是我的默认版本(我仍然希望它是)。但我不想在我的电脑上添加 rails 3.2。在以下命令中:gem install rails -v 3.2.16 我有这个警告: railt
您好,我想使用 Sheevaplug 构建一个“Rails Brick”来自 Marvell(操作系统是开箱即用的 Ubuntu,但您可以在其上安装其他发行版)。它将成为家庭服务器和静音、低成本(99
我需要能够从 Rails 控制台发送我的 Rails 应用程序的 Postgres 数据库中所有未接受的邀请。 (我有一个名为 Invitations 的表,其中包含一个名为 accepted 的 b
validate :cannot_modify_if_locked, on: :update def cannot_modify_if_locked if self.locked erro
我正在学习教程(学习 Rails 播客),需要更改以下路由语法,以便它与 Rails 3.0 兼容。谁能帮忙? map.view_page ':name', :controller => 'viewe
我是一名优秀的程序员,十分优秀!