OpenID, facebook, twitter, linkedin, etc etc

236 views
Skip to first unread message

mdipierro

unread,
Jul 15, 2010, 7:31:46 PM7/15/10
to web2py-users
I have integrated Mr Freeze RPX API into web2py (trunk only).

Take your existing app and at the bottom of db.py (or after you define
auth) add

from gluon.contrib.login_methods.rpx_account import RPXAccount

auth.settings.actions_disabled=['register','change_password','request_reset_password']
auth.settings.login_form = RPXAccount(
request,
api_key="...",
domain="...",
url = "http://localhost:8000/%s/default/user/login" %
request.application)

WHERE you can get and api_key and domain by registering (for free) at
https://rpxnow.com
you choose the domain (has to be unique) and they give you the
api_key.
The url is the URL of the login page itself as visible to your
visitors.

If you do not define your own db.auth_user table this is all you need.
If you define your own table, add a new field to it:

Field('registration_id', length=512,writable=False,
readable=False, default='')

Then visit the login page and viola' you can login with OpenID,
Google, etc etc. You can add UP to 6 methods for free using the
rpxnow.com interface. For more methods, you need to pay (I am not
affiliated with them and I get no profit but I like their system)

PLEASE TRY IT AND REPORT ANY PROBLEM.

I would like to release 1.81.1 with this tomorrow so I can show it at
EuroPython Saturday.

Massimo

mdipierro

unread,
Jul 15, 2010, 7:36:23 PM7/15/10
to web2py-users
P.S. You can also try the nightly built from http://web2py.com/examples/static/download

On 15 Lug, 18:31, mdipierro <mdipie...@cs.depaul.edu> wrote:
> I have integrated Mr Freeze RPX API into web2py (trunk only).
>
> Take your existing app and at the bottom of db.py (or after you define
> auth) add
>
>     from gluon.contrib.login_methods.rpx_account import RPXAccount
>
> auth.settings.actions_disabled=['register','change_password','request_reset_password']
>     auth.settings.login_form = RPXAccount(
>       request,
>       api_key="...",
>       domain="...",
>       url = "http://localhost:8000/%s/default/user/login" %
> request.application)
>
> WHERE you can get and api_key and domain by registering (for free) athttps://rpxnow.com

mr.freeze

unread,
Jul 15, 2010, 8:21:11 PM7/15/10
to web2py-users
Nice. One small issue on the Facebook mapping. First and last name are
under the profile's 'name' key so it throws and error. Just need to
change these two:
first_name = profile["name"]["givenName"],
last_name = profile["name"]["familyName"]

After that I was able to login to Google, Yahoo and Facebook. Now I
just need to figure out how to migrate web2pyslices accounts to this!

On Jul 15, 6:36 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> P.S. You can also try the nightly built fromhttp://web2py.com/examples/static/download

mr.freeze

unread,
Jul 15, 2010, 9:35:10 PM7/15/10
to web2py-users
Two other issues:
When embed=False, the link doesn't work (I am investigating why).
Also, I don't think you should have to click another link when
embed=False. It should just show the overlay.

mr.freeze

unread,
Jul 15, 2010, 10:52:07 PM7/15/10
to web2py-users
Actually, embed=False works fine. I think the problem was on my end.

mr.freeze

unread,
Jul 15, 2010, 11:26:45 PM7/15/10
to web2py-users
Okay, I sent you a patch to fix the Facebook mapping and also to show
the login prompt automatically when embed=False.

mat --

unread,
Jul 16, 2010, 3:15:53 AM7/16/10
to web...@googlegroups.com
After commenting out the new code at the bottom of db.py in order to enable OpenID and adding an API key and domain,
I can as a result see the OpenID logo in the welcome page when clicking the login link. 

However, when I enter my OpenID username, it goes through the login process, but eventually comes back to the Welcome login screen (with OpenID) without login me and without any error message.

This happens when testing on both trunk and 1.81.1 on local linux machine.

Am I missing something?

--
Mat

mdipierro

unread,
Jul 16, 2010, 3:36:53 AM7/16/10
to web2py-users
Do you use embed=True or False?

mat --

unread,
Jul 16, 2010, 4:10:38 AM7/16/10
to web...@googlegroups.com
I can't find the `embed=True` or `embed=False' setting in any of my files. Is it in 1.81.1?
--
Mat

mdipierro

unread,
Jul 16, 2010, 4:14:02 AM7/16/10
to web2py-users
It is an argument of RPXAccount. Defaults to true. I have no idea why
it does not work for you. Perhaps MrFreeze can help... I am about to
catch a plane. I will read more tonight.

mat --

unread,
Jul 16, 2010, 4:31:38 AM7/16/10
to web...@googlegroups.com
I found the argument in rpx_account.py and changed it. But issue is the same for True and False.

FYI i am getting this in console when running trunk version:

please visit:
use "kill -SIGTERM 6952" to shutdown the web2py server
<gluon.contrib.login_methods.rpx_account.RPXAccount object at 0x4212b50> None
<gluon.contrib.login_methods.rpx_account.RPXAccount object at 0x41a8210> None
--
Mat

mr.freeze

unread,
Jul 16, 2010, 10:22:44 AM7/16/10
to web2py-users
OpenID works for me. Did you create your own profile mapping for
OpenID or just use the default? Can you verify that your OpenID
persona has the basic information set?

mr.freeze

unread,
Jul 16, 2010, 10:25:32 AM7/16/10
to web2py-users
Also, does this only happen with OpenID?

mat --

unread,
Jul 18, 2010, 5:28:50 AM7/18/10
to web...@googlegroups.com
I got RPXAccount working now.

I think I was using the wrong domain in my settings.

Thanks.
--
Mat

hcvst

unread,
Aug 26, 2010, 4:26:19 AM8/26/10
to web2py-users

Hi,

[Version 1.83.1 (2010-08-11 23:52:55)]

I am trying to use rpx as per chapter 8 of the W2P book (http://
web2py.com/book/default/chapter/08)

from gluon.contrib.login_methods.rpx_account import RPXAccount
auth.settings.actions_disabled=['register','change_password','request_reset_password']
auth.settings.login_form = RPXAccount(request,
api_key='...',
domain='...',
url = "http://localhost:8000/%s/default/user/login" %
request.application)

I've signed up with Janrain and inserted mydomain (part of
mydomain.rpxnow.com ) and api key above.
My app uses the standard auth tables.

When I check my w2p profile after sign in with Google, the first time
round (i.e. when google asks for my email and password)
everything looks fine - firstname, lastname and email are populated.
If I log out and back in (this time I am still logged into Google and
only have to confirm) only the firstname field is filled and the DB
admin now shows two accounts in the auth table (one with the
complete and one with the partial profile).

Somehow the profile isn't matched properly (this happens both locally
and on GAE).

Do I need custom tables/mappings/... ?

Thanks,
HC

hcvst

unread,
Aug 26, 2010, 1:48:07 PM8/26/10
to web2py-users
Hi,

Just stepped though RPXAccount and for some reason Janrain returns
profile.providerName = 'Other' and no email
the second time I logon with Google, so I end up with one profile with
and
one without email. Clearly something's wrong on their side.

HC

Roma Asnani

unread,
Apr 12, 2012, 7:42:42 AM4/12/12
to web...@googlegroups.com

i am trying janrain and had created a model that contains this code. Refer from vimeo.com/21364178 building a minimalist facebook clone and deploying on google app engine using janrain.

import os
from gluon.contrib.login_methods.rpx_account import RPXAccount
# we disable actions that will be provided by Janrain, not auth
auth.settings.actions_disabled = ['register','change_password',
'request_reset_password']
# we read the key frm a file because we want to keep it private
api_key =open(os.path.join(request.folder,'private','janrain_api_key.txt'),'r').read().strip()
# we connect auth to janrain
auth.settings.login_form = RPXAccount(request, api_key=api_key,domain='web2py',

    url = "http://localhost:8000/%s/default/user/login" % request.application)

and i had created a file with name janrain_api_key.txt in app/private/ folder now in this i added the api key provided by janrain.
After all this i find my application works but it only stucks at login. It get sign in redirects to rpxnow page communicates the login information in another page graps the permission and come back to my application but still at same situation from where it starts. As the user doesn't get logged in. Can anyone specify what actually the problem is and why it lets me go back to the same login prompt.
ack t
Reply all
Reply to author
Forward
0 new messages