[web2py] gluon/contrib/login_methods/linkedin_account.py - anyone deployed this?

2010-11-15 Thread Carl
Has anyone got gluon/contrib/login_methods/linked_account.py working?

I've built directly upon /gluon/contrib/login_methods/
oauth10a_account.py with my own specific LinkedIn code but having
found http://code.google.com/p/python-linkedin/ I wanted to use this
to avoid reinventing the wheel (Özgür Vatansever's linkedin.py looks
clean and has broad support for LinkedIn's API).

But, linkedin.py doesn't look finished; for example:
(from web2py 1.89.1)

Line 43.
result = self.request.vars.verifier

The vars variable sets 'oauth_verifier' on returning from the LinkedIn
website but not 'verifier'.

Anyone tread this path?





Re: [web2py] gluon/contrib/login_methods/linkedin_account.py - anyone deployed this?

2010-11-15 Thread Michele Comitini
Never tested, just a suggestion write something similar in your model
(see: 
http://code.google.com/r/michelecomitini-facebookaccess/source/browse/applications/linkedInOauth/models/db.py):

class LinkedinTest(OAuthAccount):
def get_user(self):
if self.accessToken() is not None:
client = oauth.Client(self.consumer, self.accessToken())
resp, content =
client.request('https://api.linkedin.com/v1/people/~:(id,first-name,last-name)')
if resp['status'] != '200':
# cannot get user info. should check status
return None
x = dom.parseString(content)
firstname = x.getElementsByTagName('first-name')[0].firstChild.data
username = firstname + ' '
+x.getElementsByTagName('last-name')[0].firstChild.data
uid = x.getElementsByTagName('id')[0].firstChild.data
return dict(username=username, name=firstname, registration_id=uid)

auth.settings.login_form=LinkedinTest(globals(),CLIENT_ID,CLIENT_SECRET,
AUTH_URL, TOKEN_URL, ACCESS_TOKEN_URL)


api = LinkedIn(api_key, api_secret, callback_url)

api.access_token=auth.settings.login_form.accessToken()

now you should be able to use the linkedin api, skipping the OAuth
code embedded into it.


2010/11/15 Carl carl.ro...@gmail.com:
 Has anyone got gluon/contrib/login_methods/linked_account.py working?

 I've built directly upon /gluon/contrib/login_methods/
 oauth10a_account.py with my own specific LinkedIn code but having
 found http://code.google.com/p/python-linkedin/ I wanted to use this
 to avoid reinventing the wheel (Özgür Vatansever's linkedin.py looks
 clean and has broad support for LinkedIn's API).

 But, linkedin.py doesn't look finished; for example:
 (from web2py 1.89.1)

 Line 43.
 result = self.request.vars.verifier

 The vars variable sets 'oauth_verifier' on returning from the LinkedIn
 website but not 'verifier'.

 Anyone tread this path?