views:

249

answers:

2

Hi everyone, i am new to Python and Web2py and i am developing an app that will use the LinkedIn api

I use this library http://code.google.com/p/python-linkedin/ (it includes OAuth). My problem is very strange and that s why i am writing to the list. When i try to connect to LinkedIn from the web2py console i get a request Token. When i do it inside a HTTP request i get a signature invalid exception. The code i use in both cases is quite simple:

  li = LinkedIn(LINKEDIN_API_KEY, LINKEDIN_SECRET_KEY, URL(r=request, c='default',f='import_accounts'))
  li.requestToken()

Thanx a lot for your time

A: 

You mentioned that in both cases it is quite simple... it leaves me to wonder.

Is it the exact same code in both cases?

Thadeus
yes but tomorrow when i started my computer it was working after 15-20 requests it stopped. i guess it should be ip or domain related problem
PanosJee
+1  A: 

I just tried and it works but: 1) make sure you run this on the same hostname that you registered with linkedin 2) pass a full RETURN_URL, not a relative URL as returned by URL

def index():
  import linkedin
  from linkedin import linkedin
  RETURN_URL = "http://web2py.com/linkedin/default/hello"
  api = linkedin.LinkedIn(KEY, SECRET, RETURN_URL)
  token = api.requestToken()
  return dict(message=T('Hello World'),token=token)
mdipierro
The problem was that i was using 127.0.0.1 behing a dynamic IP, i use now a tunnel and it works fine!
PanosJee