# Problem with OpenID Plugin, please help

**URL:** <https://www.ruby-forum.com/t/problem-with-openid-plugin-please-help/113576>\
**Category:** Rails\
**Created:** [September 2, 2007, 3:32am UTC](https://www.ruby-forum.com/t/problem-with-openid-plugin-please-help/113576 "2007-09-02T03:32:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mister\_Yu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@Mister\_Yu](https://www.ruby-forum.com/u/Mister_Yu)\
**Post date:** [September 2, 2007, 3:32am UTC](https://www.ruby-forum.com/t/problem-with-openid-plugin-please-help/113576/1 "2007-09-02T03:32:12Z")

</div>

Hello all,

i was trying to follow this tutorial(  
[http://www.bencurtis.com/archives/2007/03/rails-openid-and-acts-as-authenticated/](http://www.bencurtis.com/archives/2007/03/rails-openid-and-acts-as-authenticated/)  
) and the README file to add OpenID support to my login system.

i successfully got to the point where it can login users with OpenID,  
without requiring some informations from “simple-registration-  
extension” (nickname, email, etc)

once i can login user with OpenID, i followed the README file of the  
plugin, which change the “open\_id\_authentication(identity\_url)” into:

* * *

```
  def open_id_authentication(identity_url)
    # Pass optional :required and :optional keys to specify what

```

sreg fields you want.  
# Be sure to yield registration, a third argument in the  
#authenticate\_with\_open\_id block.  
authenticate\_with\_open\_id(identity\_url,  
:required =\> [:nickname, :email]) do |status,  
identity\_url, registration|  
case status  
when :missing  
failed\_login “Sorry, the OpenID server couldn’t be found”  
when :canceled  
failed\_login “OpenID verification was canceled”  
when :failed  
failed\_login “Sorry, the OpenID verification failed”  
when :successful  
if @current\_user =  
@account.users.find\_by\_identity\_url(identity\_url)  
assign\_registration\_attributes!(registration)

```
          if current_user.save
            successful_login
          else
            failed_login "Your OpenID profile registration failed:

```

" +  
@current\_user.errors.full\_messages.to\_sentence  
end  
else  
failed\_login “Sorry, no user by that identity URL  
exists”  
end  
end  
end  
end

* * *

also added:  
def assign\_registration\_attributes!(registration)  
model\_to\_registration\_mapping.each do |model\_attribute,  
registration\_attribute|  
unless registration[registration\_attribute].blank?  
@current\_user.send(“#{model\_attribute}=”,  
registration[registration\_attribute])  
end  
end  
end

```
  def model_to_registration_mapping
    { :login => 'nickname', :email => 'email' }
  end

```

* * *

and changed:  
def login  
if using\_open\_id?  
open\_id\_authentication(params[:openid\_url])  
elsif params[:login]  
password\_authentication(params[:login], params[:password])  
end  
end

now when i login with an OpenID, it takes me to the provider, provider  
prompts that it requires email, nickname, after i hit ALLOW ONCE, it  
redirects me back to the login page, and the strange thing is, it has  
no error message or warning messages. and the url is not saved into  
the database. can some one give me some hints?

here’s the development log, hope it helps:

* * *

Processing AccountController#login (for 127.0.0.1 at 2007-09-02  
02:15:39) [POST]  
Session ID: 3cb1bf432832ad821b4334d2d61b9bea  
Parameters: {“commit”=\>“Log in”, “openid\_url”=\>“http://  
[erv2.myopenid.com/](http://erv2.myopenid.com/)”, “action”=\>“login”, “controller”=\>“account”,  
“login”=\>“”, “password”=\>“”}  
[4;36;1mOpenIdAuthentication::Nonce Load (0.000000) [0m  
[0;1mSELECT \* FROM open\_id\_authentication\_nonces WHERE  
(open\_id\_authentication\_nonces.`nonce` = ‘g9GVDNDr’) LIMIT 1 [0m  
[4;35;1mSQL (0.000000) [0m [0mBEGIN [0m  
[4;36;1mSQL (0.000000) [0m [0;1mINSERT INTO  
open\_id\_authentication\_nonces (`created`, `nonce`) VALUES(1188695740,  
‘g9GVDNDr’) [0m  
[4;35;1mSQL (0.015000) [0m [0mCOMMIT [0m  
[4;36;1mOpenIdAuthentication::Association Load (0.016000) [0m  
[0;1mSELECT \* FROM open\_id\_authentication\_associations WHERE  
(open\_id\_authentication\_associations.`server_url` = ‘http://  
[www.myopenid.com/server](http://www.myopenid.com/server)’) [0m  
Redirected to  
[http://www.myopenid.com/server?openid.mode=checkid\_setup&openid.return\_to=http%3A%2F%2Flocalhost%3A3000%2Faccount%2Flogin%3Fopen\_id\_complete%3D1%26nonce%3Dg9GVDNDr%26nonce%3Dg9GVDNDr&openid.sreg.required=nickname%2Cemail&openid.trust\_root=http%3A%2F%2Flocalhost%3A3000%2F&openid.identity=http%3A%2F%2Ferv2.myopenid.com%2F&openid.assoc\_handle={HMAC-SHA1}{46d9e682}{7JwLmA%3D%3D}](http://www.myopenid.com/server?openid.mode=checkid_setup&openid.return_to=http%3A%2F%2Flocalhost%3A3000%2Faccount%2Flogin%3Fopen_id_complete%3D1%26nonce%3Dg9GVDNDr%26nonce%3Dg9GVDNDr&openid.sreg.required=nickname%2Cemail&openid.trust_root=http%3A%2F%2Flocalhost%3A3000%2F&openid.identity=http%3A%2F%2Ferv2.myopenid.com%2F&openid.assoc_handle=%7BHMAC-SHA1%7D%7B46d9e682%7D%7B7JwLmA%3D%3D%7D)  
Completed in 0.42200 (2 reqs/sec) | DB: 0.03100 (7%) | 302 Found  
[[http://localhost/account/login](http://localhost/account/login)]

Processing AccountController#login (for 127.0.0.1 at 2007-09-02  
02:17:05) [GET]  
Session ID: 3cb1bf432832ad821b4334d2d61b9bea  
Parameters: {“openid.sreg.nickname”=\>“erv2”,  
“openid.mode”=\>“id\_res”, “openid.return\_to”=\>“[http://localhost:3000/](http://localhost:3000/)  
account/login?open\_id\_complete=1&nonce=g9GVDNDr&nonce=g9GVDNDr”,  
“openid.sig”=\>“H1uytnVNpb3zeCmsdMdqMFWygzI=”,  
“openid.op\_endpoint”=\>“[http://www.myopenid.com/server](http://www.myopenid.com/server)”,  
“openid.response\_nonce”=\>“2007-09-02T01:16:57ZfnpIUD”,  
“action”=\>“login”, “openid.sreg.email”=\>“removed\_email\_address@domain.invalid”,  
“controller”=\>“account”, “openid.identity”=\>“http://  
[erv2.myopenid.com/](http://erv2.myopenid.com/)”, “open\_id\_complete”=\>“1”, “nonce”=\>“g9GVDNDr”,  
“openid.assoc\_handle”=\>“{HMAC-SHA1}{46d9e682}{7JwLmA==}”,  
“openid.signed”=\>“assoc\_handle,identity,mode,op\_endpoint,response\_nonce,return\_to,signed,sreg.email,sreg.nickname”}  
[4;35;1mOpenIdAuthentication::Association Load (0.000000) [0m  
[0mSELECT \* FROM open\_id\_authentication\_associations WHERE  
(open\_id\_authentication\_associations.`handle` = ‘{HMAC-SHA1}{46d9e682}  
{7JwLmA==}’ AND open\_id\_authentication\_associations.`server_url` =  
‘[http://www.myopenid.com/server](http://www.myopenid.com/server)’) [0m  
[4;36;1mOpenIdAuthentication::Nonce Load (0.000000) [0m  
[0;1mSELECT \* FROM open\_id\_authentication\_nonces WHERE  
(open\_id\_authentication\_nonces.`nonce` = ‘g9GVDNDr’) LIMIT 1 [0m  
[4;35;1mSQL (0.000000) [0m [0mBEGIN [0m  
[4;36;1mOpenIdAuthentication::Nonce Destroy (0.000000) [0m [0;1m  
DELETE FROM open\_id\_authentication\_nonces  
WHERE `id` = 10  
[0m  
[4;35;1mSQL (0.032000) [0m [0mCOMMIT [0m  
Rendering within layouts/account  
Rendering account/login  
Completed in 0.06300 (15 reqs/sec) | Rendering: 0.00000 (0%) | DB:  
0.03200 (50%) | 200 OK [[http://localhost/account/login](http://localhost/account/login)?  
open\_id\_complete=1&nonce=g9GVDNDr&nonce=g9GVDNDr&openid.assoc\_handle=  
%7BHMAC-SHA1%7D%7B46d9e682%7D%7B7JwLmA%3D%3D%7D&openid.identity=http%3A  
%2F%[2Ferv2.myopenid.com](http://2Ferv2.myopenid.com)%2F&openid.mode=id\_res&openid.op\_endpoint=http  
%3A%2F%[2Fwww.myopenid.com](http://2Fwww.myopenid.com)  
%2Fserver&openid.response\_nonce=2007-09-02T01%3A16%3A57ZfnpIUD&openid.return\_to=http  
%3A%2F%2Flocalhost%3A3000%2Faccount%2Flogin%3Fopen\_id\_complete  
%3D1%26nonce%3Dg9GVDNDr%26nonce  
%3Dg9GVDNDr&openid.sig=H1uytnVNpb3zeCmsdMdqMFWygzI  
%3D&openid.signed=assoc\_handle%2Cidentity%2Cmode%2Cop\_endpoint  
%2Cresponse\_nonce%2Creturn\_to%2Csigned%2Csreg.email  
%2Csreg.nickname&openid.sreg.email=earrth2%[40gmail.com](http://40gmail.com)&openid.sreg.nickname=erv2]

---

<div class="post-metadata">

**Author:** ![Mister\_Yu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/22d042/32.png) [@Mister\_Yu](https://www.ruby-forum.com/u/Mister_Yu)\
**Post date:** [September 3, 2007, 3:20am UTC](https://www.ruby-forum.com/t/problem-with-openid-plugin-please-help/113576/2 "2007-09-03T03:20:13Z")

</div>

Try the updated version and email me if you continue to have problems  
with it:

[http://www.bencurtis.com/archives/2007/07/openid-sample-application-](http://www.bencurtis.com/archives/2007/07/openid-sample-application-)  
updated/

–  
Benjamin C.  
[http://www.bencurtis.com/](http://www.bencurtis.com/) – blog  
[http://agilewebdevelopment.com/guides/](http://agilewebdevelopment.com/guides/) – Rails HOWTOs
