I am putting together a web service for a mobile app and am getting the error message after authenticating. My client is an iOS app and it is able to pass the authorization part and I see records being created in the oauth2_authorization_codes table. The problem is that it fails when attempting to set the refresh token. Any help would be appreciated.
I put some print statements in the devise/oauth2_providable/tokens_controller.rb to see what was going on. Below is the terminal output with my debug statements:
Started POST "/oauth2/authorizations" for 127.0.0.1 at 2012-12-11 17:07:17 -1000
Processing by Devise::Oauth2Providable::AuthorizationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"INzYLPAAzzVTH7bDKuVItFkDzAmfMrJWNvkMQGbbAoE=", "client_id"=>"dd58eef1c489c744742546
abe08ca6b9", "response_type"=>"code", "redirect_uri"=>"http://127.0.0.1", "commit"=>"Approve", "approve"=>"true"}
User Load (0.3ms) SELECT 'users'.* FROM 'users' WHERE 'users'.'id' = 2 LIMIT 1
Devise::Oauth2Providable::Client Load (0.4ms) SELECT 'oauth2_clients'.* FROM 'oauth2_clients' WHERE 'oauth2_clients'.'identifier' =
'dd58eef1c489c744742546abe08ca6b9' LIMIT 1
(0.1ms) BEGIN
Devise::Oauth2Providable::AuthorizationCode Exists (0.4ms) SELECT 1 AS one FROM 'oauth2_authorization_codes' WHERE 'oauth2_authorization_codes'.'token' = BINARY '19422126acf59290e4a77bd7338e19e1' LIMIT 1
SQL (0.4ms) INSERT INTO 'oauth2_authorization_codes' ('client_id', 'created_at', 'expires_at', 'token', 'updated_at', 'user_id') VALUES (1, '2012-12-12 03:07:17', '2012-12-12 03:08:17', '19422126acf59290e4a77bd7338e19e1', '2012-12-12 03:07:17', 2)
(0.9ms) COMMIT
Redirected to http://127.0.0.1?code=19422126acf59290e4a77bd7338e19e1
Completed 302 Found in 12ms (ActiveRecord: 2.6ms)
========== current_user
--- !ruby/object:User
attributes:
id: 2
email: developer@upspringmedia.com
encrypted_password: $2a$10$IyV3ZQY1OQawLx2Y0VJe7OlmWH28poe6j94C8f9XTn9sAKQLH2DaO
reset_password_token: !!null
reset_password_sent_at: !!null
remember_created_at: !!null
sign_in_count: 11
current_sign_in_at: 2012-12-12 02:29:31.000000000Z
last_sign_in_at: 2012-12-11 22:35:02.000000000Z
current_sign_in_ip: 127.0.0.1
last_sign_in_ip: 127.0.0.1
authentication_token: !!null
created_at: 2012-12-03 19:55:18.000000000Z
updated_at: 2012-12-12 02:29:31.000000000Z
provider: !!null
uid: !!null
role: developer
========== oauth2_current_refresh_token
========== env[Devise::Oauth2Providable::REFRESH_TOKEN_ENV_REF]
========== oauth2_current_client
========== env[Devise::Oauth2Providable::CLIENT_ENV_REF]
--- !!null
...
========== env[Devise::Oauth2Providable::REFRESH_TOKEN_ENV_REF]
========== env[Devise::Oauth2Providable::CLIENT_ENV_REF]
Started POST "/oauth2/token?grant_type=authorization_code&client_secret=[FILTERED]&code=19422126acf59290e4a77bd7338e19e1&redirect_uri=
http://127.0.0.1&client_id=dd58eef1c489c744742546abe08ca6b9" for 127.0.0.1 at 2012-12-11 17:07:17 -1000
Processing by Devise::Oauth2Providable::TokensController#create as */*
Parameters: {"grant_type"=>"authorization_code", "client_secret"=>"[FILTERED]", "code"=>"19422126acf59290e4a77bd7338e19e1", "redirec
t_uri"=>"http://127.0.0.1", "client_id"=>"dd58eef1c489c744742546abe08ca6b9"}
User Load (0.3ms) SELECT 'users'.* FROM `users` WHERE 'users'.'id' = 2 LIMIT 1
Completed 500 Internal Server Error in 4ms
NoMethodError (undefined method `refresh_tokens' for nil:NilClass):
I have tried clearing the session cookie using session.clear in the TokensController, and am now getting the oauth2_current_client but still no refresh_tokens.
I am putting together a web service for a mobile app and am getting the error message after authenticating. My client is an iOS app and it is able to pass the authorization part and I see records being created in the oauth2_authorization_codes table. The problem is that it fails when attempting to set the refresh token. Any help would be appreciated.
I put some print statements in the devise/oauth2_providable/tokens_controller.rb to see what was going on. Below is the terminal output with my debug statements:
Thanks,
David