Re: [web2py] Re: Enabling Google Sign-In

2016-01-24 Thread Massimo Di Pierro
from gluon.storage import Storage

On Thursday, 21 January 2016 08:42:47 UTC-6, dirman wrote:
>
> hi 
> am getting  global name 'Storage' is not 
> defined
> when using  Storage(json.load(f)['web'])
>
>
>
> On Thursday, October 22, 2015 at 11:27:35 AM UTC, mcm wrote:
>>
>>
>> http://web2py.com/books/default/chapter/29/09/access-control?search=oauth#Other-login-methods-and-login-forms
>>
>>
>> Grab the file google_auth.json from the google developer console and put 
>> in private dir of your app
>>
>> put  code similar to the one below in db.py:
>>
>>
>> from gluon.contrib.login_methods.oauth20_account import OAuthAccount
>>
>> try:
>> import json
>> except ImportError:
>> from gluon.contrib import simplejson as json
>>
>>
>> class GoogleAccount(OAuthAccount):
>> "OAuth 2.0 for Google"
>>
>> def __init__(self):
>> with open(os.path.join(request.folder, 
>> 'private/google_auth.json'), 'rb') as f:
>> gai = Storage(json.load(f)['web'])
>> 
>> OAuthAccount.__init__(self, None, gai.client_id, 
>> gai.client_secret,
>>   gai.auth_uri, gai.token_uri,
>>   scope='
>> https://www.googleapis.com/auth/userinfo.profile 
>> https://www.googleapis.com/auth/userinfo.email',
>>   approval_prompt='force', 
>> state="auth_provider=google")
>>
>>
>> def get_user(self):
>>
>> token = self.accessToken()
>> if not token:
>> return None
>>
>> uinfo_url = '
>> https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' % 
>> urllib2.quote(token, safe='')
>>
>> uinfo = None
>>
>> try:
>> uinfo_stream = urllib2.urlopen(uinfo_url)
>> except:
>> session.token = None
>> return
>> data = uinfo_stream.read()
>> uinfo = json.loads(data)
>>
>> username = uinfo['id']
>> 
>> return dict(first_name = uinfo['given_name'],
>> last_name = uinfo['family_name'],
>> username = username,
>> email = uinfo['email'])
>>
>> auth.settings.login_form = GoogleAccount()
>>
>>
>> 2015-10-22 11:02 GMT+02:00 Leonel Câmara :
>>
>>> I would try to use this:
>>>
>>> https://code.google.com/p/w2p-social-auth/
>>>
>>> -- 
>>> 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 web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Enabling Google Sign-In

2016-01-21 Thread dirman
hi 
am getting  global name 'Storage' is not 
defined
when using  Storage(json.load(f)['web'])



On Thursday, October 22, 2015 at 11:27:35 AM UTC, mcm wrote:
>
>
> http://web2py.com/books/default/chapter/29/09/access-control?search=oauth#Other-login-methods-and-login-forms
>
>
> Grab the file google_auth.json from the google developer console and put 
> in private dir of your app
>
> put  code similar to the one below in db.py:
>
>
> from gluon.contrib.login_methods.oauth20_account import OAuthAccount
>
> try:
> import json
> except ImportError:
> from gluon.contrib import simplejson as json
>
>
> class GoogleAccount(OAuthAccount):
> "OAuth 2.0 for Google"
>
> def __init__(self):
> with open(os.path.join(request.folder, 
> 'private/google_auth.json'), 'rb') as f:
> gai = Storage(json.load(f)['web'])
> 
> OAuthAccount.__init__(self, None, gai.client_id, gai.client_secret,
>   gai.auth_uri, gai.token_uri,
>   scope='
> https://www.googleapis.com/auth/userinfo.profile 
> https://www.googleapis.com/auth/userinfo.email',
>   approval_prompt='force', 
> state="auth_provider=google")
>
>
> def get_user(self):
>
> token = self.accessToken()
> if not token:
> return None
>
> uinfo_url = '
> https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' % 
> urllib2.quote(token, safe='')
>
> uinfo = None
>
> try:
> uinfo_stream = urllib2.urlopen(uinfo_url)
> except:
> session.token = None
> return
> data = uinfo_stream.read()
> uinfo = json.loads(data)
>
> username = uinfo['id']
> 
> return dict(first_name = uinfo['given_name'],
> last_name = uinfo['family_name'],
> username = username,
> email = uinfo['email'])
>
> auth.settings.login_form = GoogleAccount()
>
>
> 2015-10-22 11:02 GMT+02:00 Leonel Câmara  >:
>
>> I would try to use this:
>>
>> https://code.google.com/p/w2p-social-auth/
>>
>> -- 
>> 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 web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Enabling Google Sign-In

2015-10-24 Thread Donald McClymont
It is on github at https://github.com/bnmnetp/w2p-social-auth  but doesn't 
appear to be getting maintained.

I agree it would be good if it was more promoted - it seems to work but is 
using version 0.1.24 or so of psa which is a good bit behind latest version 
- but it seems to work fine with Facebook, Twitter and Mozilla Persona in 
some way allows emails from Google and the like - however I have yet to get 
Google or Microsoft to work.

On Thursday, October 22, 2015 at 9:54:52 PM UTC+1, mcm wrote:
>
> yup it would be nice if it were maintained and moved to github...
>
> 2015-10-22 17:40 GMT+02:00 Niphlod :
>
>> I didn't know about w2p-social-auth and I'm starting to thinking that we 
>> should "promote it" and discourage all social-own-cooked pieces inside 
>> contrib/login_methods...
>>
>>
>> On Thursday, October 22, 2015 at 1:27:35 PM UTC+2, mcm wrote:
>>
>>>
>>> http://web2py.com/books/default/chapter/29/09/access-control?search=oauth#Other-login-methods-and-login-forms
>>>
>>>
>>> Grab the file google_auth.json from the google developer console and put 
>>> in private dir of your app
>>>
>>> put  code similar to the one below in db.py:
>>>
>>>
>>> from gluon.contrib.login_methods.oauth20_account import OAuthAccount
>>>
>>> try:
>>> import json
>>> except ImportError:
>>> from gluon.contrib import simplejson as json
>>>
>>>
>>> class GoogleAccount(OAuthAccount):
>>> "OAuth 2.0 for Google"
>>>
>>> def __init__(self):
>>> with open(os.path.join(request.folder, 
>>> 'private/google_auth.json'), 'rb') as f:
>>> gai = Storage(json.load(f)['web'])
>>> 
>>> OAuthAccount.__init__(self, None, gai.client_id, 
>>> gai.client_secret,
>>>   gai.auth_uri, gai.token_uri,
>>>   scope='
>>> https://www.googleapis.com/auth/userinfo.profile 
>>> https://www.googleapis.com/auth/userinfo.email',
>>>   approval_prompt='force', 
>>> state="auth_provider=google")
>>>
>>>
>>> def get_user(self):
>>>
>>> token = self.accessToken()
>>> if not token:
>>> return None
>>>
>>> uinfo_url = '
>>> https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' % 
>>> urllib2.quote(token, safe='')
>>>
>>> uinfo = None
>>>
>>> try:
>>> uinfo_stream = urllib2.urlopen(uinfo_url)
>>> except:
>>> session.token = None
>>> return
>>> data = uinfo_stream.read()
>>> uinfo = json.loads(data)
>>>
>>> username = uinfo['id']
>>> 
>>> return dict(first_name = uinfo['given_name'],
>>> last_name = uinfo['family_name'],
>>> username = username,
>>> email = uinfo['email'])
>>>
>>> auth.settings.login_form = GoogleAccount()
>>>
>>>
>>> 2015-10-22 11:02 GMT+02:00 Leonel Câmara :
>>>
 I would try to use this:

 https://code.google.com/p/w2p-social-auth/

 -- 
 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 web2py+un...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> -- 
>> 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 web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Enabling Google Sign-In

2015-10-22 Thread Michele Comitini
http://web2py.com/books/default/chapter/29/09/access-control?search=oauth#Other-login-methods-and-login-forms


Grab the file google_auth.json from the google developer console and put in
private dir of your app

put  code similar to the one below in db.py:


from gluon.contrib.login_methods.oauth20_account import OAuthAccount

try:
import json
except ImportError:
from gluon.contrib import simplejson as json


class GoogleAccount(OAuthAccount):
"OAuth 2.0 for Google"

def __init__(self):
with open(os.path.join(request.folder, 'private/google_auth.json'),
'rb') as f:
gai = Storage(json.load(f)['web'])

OAuthAccount.__init__(self, None, gai.client_id, gai.client_secret,
  gai.auth_uri, gai.token_uri,
  scope='
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/userinfo.email',
  approval_prompt='force',
state="auth_provider=google")


def get_user(self):

token = self.accessToken()
if not token:
return None

uinfo_url = '
https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' %
urllib2.quote(token, safe='')

uinfo = None

try:
uinfo_stream = urllib2.urlopen(uinfo_url)
except:
session.token = None
return
data = uinfo_stream.read()
uinfo = json.loads(data)

username = uinfo['id']

return dict(first_name = uinfo['given_name'],
last_name = uinfo['family_name'],
username = username,
email = uinfo['email'])

auth.settings.login_form = GoogleAccount()


2015-10-22 11:02 GMT+02:00 Leonel Câmara :

> I would try to use this:
>
> https://code.google.com/p/w2p-social-auth/
>
> --
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Enabling Google Sign-In

2015-10-22 Thread Michele Comitini
yup it would be nice if it were maintained and moved to github...

2015-10-22 17:40 GMT+02:00 Niphlod :

> I didn't know about w2p-social-auth and I'm starting to thinking that we
> should "promote it" and discourage all social-own-cooked pieces inside
> contrib/login_methods...
>
>
> On Thursday, October 22, 2015 at 1:27:35 PM UTC+2, mcm wrote:
>
>>
>> http://web2py.com/books/default/chapter/29/09/access-control?search=oauth#Other-login-methods-and-login-forms
>>
>>
>> Grab the file google_auth.json from the google developer console and put
>> in private dir of your app
>>
>> put  code similar to the one below in db.py:
>>
>>
>> from gluon.contrib.login_methods.oauth20_account import OAuthAccount
>>
>> try:
>> import json
>> except ImportError:
>> from gluon.contrib import simplejson as json
>>
>>
>> class GoogleAccount(OAuthAccount):
>> "OAuth 2.0 for Google"
>>
>> def __init__(self):
>> with open(os.path.join(request.folder,
>> 'private/google_auth.json'), 'rb') as f:
>> gai = Storage(json.load(f)['web'])
>>
>> OAuthAccount.__init__(self, None, gai.client_id,
>> gai.client_secret,
>>   gai.auth_uri, gai.token_uri,
>>   scope='
>> https://www.googleapis.com/auth/userinfo.profile
>> https://www.googleapis.com/auth/userinfo.email',
>>   approval_prompt='force',
>> state="auth_provider=google")
>>
>>
>> def get_user(self):
>>
>> token = self.accessToken()
>> if not token:
>> return None
>>
>> uinfo_url = '
>> https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' %
>> urllib2.quote(token, safe='')
>>
>> uinfo = None
>>
>> try:
>> uinfo_stream = urllib2.urlopen(uinfo_url)
>> except:
>> session.token = None
>> return
>> data = uinfo_stream.read()
>> uinfo = json.loads(data)
>>
>> username = uinfo['id']
>>
>> return dict(first_name = uinfo['given_name'],
>> last_name = uinfo['family_name'],
>> username = username,
>> email = uinfo['email'])
>>
>> auth.settings.login_form = GoogleAccount()
>>
>>
>> 2015-10-22 11:02 GMT+02:00 Leonel Câmara :
>>
>>> I would try to use this:
>>>
>>> https://code.google.com/p/w2p-social-auth/
>>>
>>> --
>>> 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 web2py+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: Enabling Google Sign-In

2015-10-22 Thread Leonel Câmara
I would try to use this:

https://code.google.com/p/w2p-social-auth/

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [web2py] Re: Enabling Google Sign-In

2015-10-22 Thread Niphlod
I didn't know about w2p-social-auth and I'm starting to thinking that we 
should "promote it" and discourage all social-own-cooked pieces inside 
contrib/login_methods...

On Thursday, October 22, 2015 at 1:27:35 PM UTC+2, mcm wrote:
>
>
> http://web2py.com/books/default/chapter/29/09/access-control?search=oauth#Other-login-methods-and-login-forms
>
>
> Grab the file google_auth.json from the google developer console and put 
> in private dir of your app
>
> put  code similar to the one below in db.py:
>
>
> from gluon.contrib.login_methods.oauth20_account import OAuthAccount
>
> try:
> import json
> except ImportError:
> from gluon.contrib import simplejson as json
>
>
> class GoogleAccount(OAuthAccount):
> "OAuth 2.0 for Google"
>
> def __init__(self):
> with open(os.path.join(request.folder, 
> 'private/google_auth.json'), 'rb') as f:
> gai = Storage(json.load(f)['web'])
> 
> OAuthAccount.__init__(self, None, gai.client_id, gai.client_secret,
>   gai.auth_uri, gai.token_uri,
>   scope='
> https://www.googleapis.com/auth/userinfo.profile 
> https://www.googleapis.com/auth/userinfo.email',
>   approval_prompt='force', 
> state="auth_provider=google")
>
>
> def get_user(self):
>
> token = self.accessToken()
> if not token:
> return None
>
> uinfo_url = '
> https://www.googleapis.com/oauth2/v1/userinfo?access_token=%s' % 
> urllib2.quote(token, safe='')
>
> uinfo = None
>
> try:
> uinfo_stream = urllib2.urlopen(uinfo_url)
> except:
> session.token = None
> return
> data = uinfo_stream.read()
> uinfo = json.loads(data)
>
> username = uinfo['id']
> 
> return dict(first_name = uinfo['given_name'],
> last_name = uinfo['family_name'],
> username = username,
> email = uinfo['email'])
>
> auth.settings.login_form = GoogleAccount()
>
>
> 2015-10-22 11:02 GMT+02:00 Leonel Câmara  >:
>
>> I would try to use this:
>>
>> https://code.google.com/p/w2p-social-auth/
>>
>> -- 
>> 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 web2py+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.