I've been following the instructions at 
http://code.google.com/p/python-linkedin/
to add linkedin authentication. I grabbed the latest revision (#20)
from svn.

I've started by creating a new app (and called it oauth) within web2py
to keep things simple.

Into default.py I've added the following functions (and I've defined
my own KEY and SECRET in db.py). When I enter 
http://127.0.0.1:8000/oauth/default/linkedin
I am redirected to the LinkedIn website where I can give permission to
log in. Once I do that I am redirected to 
http://127.0.0.1:8000/oauth/default/profile/
Here I can retrieve request.vars.oauth_verifier for a call to
api.accessToken(). however, the return value is False and a call to
api.getRequestTokenError() returns "permission_unknown". I can't find
out what is causing this error.

Any ideas?

def linkedin():
  RETURN_URL = "http://127.0.0.1:8000/oauth/default/profile/";
  import gluon.contrib.login_methods.linkedin
  from gluon.contrib.login_methods.linkedin import LinkedIn
  api = LinkedIn(KEY, SECRET, RETURN_URL)
  token = api.requestToken()
  if not api.getRequestTokenError():
      u = api.getAuthorizeURL(request_token=api.request_token)
      redirect(u)
  return dict(message=T('Hello World'),token=token,
request_token=api.request_token,
token_secret=api.request_token_secret)

def profile():
    oauth_token = request.vars.oauth_token
    oauth_verifier = request.vars.oauth_verifier

    RETURN_URL = "http://127.0.0.1:8000/oauth/default/more/";
    import gluon.contrib.login_methods.linkedin
    from gluon.contrib.login_methods.linkedin import LinkedIn
    api = LinkedIn(KEY, SECRET, RETURN_URL)
    token = api.requestToken()
    result = api.accessToken(verifier=oauth_verifier)
    profile = None
    if result:
        profile = api.GetProfile(url='http://www.linkedin.com/in/
carlroach')
    else:
        print api.getRequestTokenError()

    return dict(message=T('Profile info'), profile=profile)

def more():
    return dict(message='more')

Reply via email to