I am trying to make a tiny example to login my app via google oauth2. 
However, I always got  "This webpage has a redirect loop" error from the 
browser if I use @auth.requires_login() pragma.

Model Code:
from gluon.contrib.login_methods.oauth20_account import OAuthAccount
auth.settings.login_form=OAuthAccount(
         client_id="XXXXXXX.apps.googleusercontent.com",
         client_secret="YYYYYYY",
         auth_url="https://accounts.google.com/o/oauth2/auth";,
         token_url="https://accounts.google.com/o/oauth2/token";,
         scope="openid profile email")


Controller code:
@auth.requires_login()
def index():
    return dict(message="index")


Redirect URL set in google API console: 
https://www.limijd.me/example_oauth2/default/user/login


I have tried to use web2py's build-in local authentication method by 
removing my code in model instead of using oauth2. Then the URL redirecting 
is good.

I have read the web2py manual book, in 9.1.2, it says for Janrain:
When a new user logins for the first time, web2py creates a new db.auth_user 
record associated to the user. It will use the registration_id field to 
store a unique id for the user.


However for OAuth2 login, apparently there is no new record created in 
db.auth_user like what web2py will do for Janrain. My suspicion is even I 
successfully logged in via OAuth2, web2py still doesn't consider I was 
logged in. I have removed the @auth.requires_login() and I am able to get 
the valid accessToken(). 

Please help if you know what could be the issue... 

Thanks a lot.
Wei



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to