{"action":"opened","issue":{"url":"https://api.github.com/repos/danieljacobarcher/omniauth-square/issues/7","labels_url":"https://api.github.com/repos/danieljacobarcher/omniauth-square/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/danieljacobarcher/omniauth-square/issues/7/comments","events_url":"https://api.github.com/repos/danieljacobarcher/omniauth-square/issues/7/events","html_url":"https://github.com/danieljacobarcher/omniauth-square/issues/7","id":86590790,"number":7,"title":"NoMethodError - undefined method `inject' for nil:NilClass","user":{"login":"vdolgishev","id":1975860,"avatar_url":"https://avatars.githubusercontent.com/u/1975860?v=3","gravatar_id":"","url":"https://api.github.com/users/vdolgishev","html_url":"https://github.com/vdolgishev","followers_url":"https://api.github.com/users/vdolgishev/followers","following_url":"https://api.github.com/users/vdolgishev/following{/other_user}","gists_url":"https://api.github.com/users/vdolgishev/gists{/gist_id}","starred_url":"https://api.github.com/users/vdolgishev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vdolgishev/subscriptions","organizations_url":"https://api.github.com/users/vdolgishev/orgs","repos_url":"https://api.github.com/users/vdolgishev/repos","events_url":"https://api.github.com/users/vdolgishev/events{/privacy}","received_events_url":"https://api.github.com/users/vdolgishev/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-09T12:56:10Z","updated_at":"2015-06-09T12:56:10Z","closed_at":null,"body":"Here is most useful part of stack trace: \r\n```\r\nNoMethodError - undefined method `inject' for nil:NilClass:\r\n  omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:91:in `deep_symbolize'\r\n  omniauth-square (1.0.2) lib/omniauth/strategies/square.rb:45:in `build_access_token'\r\n  omniauth-oauth2 (1.1.1) lib/omniauth/strategies/oauth2.rb:74:in `callback_phase'\r\n```\r\n\r\nI have such configs for Rails 3.2 app:\r\n```\r\n#config/inititalizers/devise.rb \r\n ...\r\n  config.omniauth :square, ENV['square_id'], ENV['square_secret'],\r\n    :client_options => {\r\n      site: 'https://squareup.com',\r\n      connect_site: 'https://connect.squareup.com'\r\n    }\r\n ...\r\n```\r\nI tried gem with the simple sinatra app(with the same key and secret) and it works successfully. I debugged and found that the issue is occurring because of key 'auth_token_params' is absent in the hash, which method `options` provides. That's why such line is raising error.\r\n```\r\ndef build_access_token\r\n  ...\r\n  parsed_response.merge!(deep_symbolize(options.auth_token_params))\r\n  ...\r\nend\r\n```\r\n\r\nHere are options hashes for both cases:\r\n```\r\n#Rails app:\r\n    options = {\r\n      \"setup\"=>false,\r\n      \"skip_info\"=>false,\r\n      \"client_id\"=>\"my_client_id\",\r\n      \"client_secret\"=>\"my_secret\",\r\n      \"client_options\"=>{\"site\"=>\"https://squareup.com\", \"connect_site\"=>\"https://connect.squareup.com\", \"authorize_url\"=>\"/   oauth2/authorize\", \"token_url\"=>\"/oauth2/token\"},\r\n      \"authorize_params\"=>{\"state\"=>\"49964d01e5a97fa44342f1cce1350c97d904307460783318\"},\r\n      \"authorize_options\"=>[:scope],\r\n      \"token_params\"=>{},\r\n      \"token_options\"=>[],\r\n      \"provider_ignores_state\"=>false,\r\n      \"name\"=>\"square\"\r\n    }\r\n\r\n#Sinatra app:\r\n  options =  {\r\n    \"setup\"=>false,\r\n    \"skip_info\"=>false,\r\n    \"client_id\"=>\"my_client_id\",\r\n    \"client_secret\"=>\"my_secret\",\r\n    \"client_options\"=>{\"site\"=>\"https://squareup.com\", \"connect_site\"=>\"https://connect.squareup.com\", \"authorize_url\"=>\"/oauth2/authorize\", \"token_url\"=>\"/oauth2/token\"},\r\n    \"authorize_params\"=>{},\r\n    \"authorize_options\"=>[:scope],\r\n    \"token_params\"=>{},\r\n    \"token_options\"=>[],\r\n    \"auth_token_params\"=>{},\r\n    \"provider_ignores_state\"=>false,\r\n    \"name\"=>\"square\"\r\n  }\r\n```\r\n"}}