Trouble using the http://code.google.com/p/python-linkedin/

68 views
Skip to first unread message

John OBrien

unread,
Aug 4, 2011, 9:36:32 AM8/4/11
to google-a...@googlegroups.com
Hiya,

I'm a bit of a newbie, so I apologize if the answer to this question is obvious. I'm having a bit of trouble using the python linkedin library (http://code.google.com/p/python-linkedin/).

When I attempt to use the library from an interactive Python interpreter, it works great:

import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
/Library/Frameworks/Python.
framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)]
>>KEY = "xxxxxx"
>>SECRET = "xxx"
>>RETURN_URL = "http://localhost:8080/settings/linkedin/return"
>>from linkedin import linkedin
>>api = linkedin.LinkedIn(KEY, SECRET, RETURN_URL)
>>result = api.requestToken()
>>print result
True
>>print api.getRequestTokenError()
None


However, when I wrap a Google App Engine webapp.RequestHandler around it, I get an error:

from linkedin import linkedin


from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app


class LinkedInSettings(webapp.RequestHandler):
    def get(self):
        KEY = "xxxx"
        SECRET = "xxxx"
        RETURN_URL = "http://localhost:8080/settings/linkedin/return"
        api = linkedin.LinkedIn(KEY, SECRET, RETURN_URL)
        result = api.requestToken()
        print result
        print api.getRequestTokenError()
       
application = webapp.WSGIApplication([('/settings/linkedin.*', LinkedInSettings)])


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()


This a request to http://localhost:8080/settings/linkedin will print out:

False
signature_invalid
Status: 200 OK
Content-Type: text/html; charset=utf-8


Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 0

Have anyone ever encountered this behavior before? Do you happen to have any ideas as to what is going on that might explain why the signature is valid when the code is executed from the interpreter, but invalid when executed within the webapp.RequestHandler class?

Thank you for time,

Regards,

John

Chris Copeland

unread,
Aug 4, 2011, 5:44:04 PM8/4/11
to google-a...@googlegroups.com
Hi John,

This is a just a guess since I haven't used that library:  when you're running in GAE, urllib (which the linkedin lib uses) is actually a wrapper for GAE's URL Fetch.  GAE's URL Fetch removes some headers and adds others.  If any of those headers are included in generating the checksum, then that would be your problem. 

-Chris

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/DJNLZfBcZhgJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Tito

unread,
Aug 24, 2011, 10:10:29 AM8/24/11
to Google App Engine
I am having the same issue as John, i.e. the python linked library
works from the python interpreter but gives signature_invalid error
when run on GAE development server or production server.

I rewrote the library to use urlfetch directly, instead of urllib, but
I got the same error.

It is true that urlfetch changes headers, but those do not enter the
signature calculation.

On Aug 4, 11:44 pm, Chris Copeland <ch...@cope360.com> wrote:
> Hi John,
>
> This is a just a guess since I haven't used that library:  when you're
> running in GAE, urllib (which the linkedin lib uses) is actually a wrapper
> for GAE's URL Fetch.  GAE's URL Fetch removes some headers and adds others.
> If any of those headers are included in generating the checksum, then that
> would be your problem.
>
> -Chris
>
> On Thu, Aug 4, 2011 at 8:36 AM, John OBrien <john.obr...@job-buddy.com>wrote:
>
>
>
>
>
>
>
> > Hiya,
>
> > I'm a bit of a newbie, so I apologize if the answer to this question is
> > obvious. I'm having a bit of trouble using the python linkedin library (
> >http://code.google.com/p/python-linkedin/).
>
> > When I attempt to use the library from an interactive Python interpreter,
> > it works great:
>
> > import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
> > /Library/Frameworks/Python.
> > framework/Versions/2.5/**Resources/Python.app/Contents/**MacOS/Python
> > 2.5.4 (r254:67917, Dec 23 2008, 14:57:27)
> > [GCC 4.0.1 (Apple Computer, Inc. build 5363)]
> > >>KEY = "xxxxxx"
> > >>SECRET = "xxx"
> > >>RETURN_URL = "http://localhost:8080/**settings/linkedin/return<http://localhost:8080/settings/linkedin/return>
> > "
> > >>from linkedin import linkedin
> > >>api = linkedin.LinkedIn(KEY, SECRET, RETURN_URL)
> > >>result = api.requestToken()
> > >>print result
> > True
> > >>print api.getRequestTokenError()
> > None
>
> > However, when I wrap a Google App Engine webapp.RequestHandler around it, I
> > get an error:
>
> > from linkedin import linkedin
>
> > from google.appengine.ext import webapp
> > from google.appengine.ext.webapp.**util import run_wsgi_app
>
> > class LinkedInSettings(webapp.**RequestHandler):
> >     def get(self):
> >         KEY = "xxxx"
> >         SECRET = "xxxx"
> >         RETURN_URL = "http://localhost:8080/**settings/linkedin/return<http://localhost:8080/settings/linkedin/return>
> > "
> >         api = linkedin.LinkedIn(KEY, SECRET, RETURN_URL)
> >         result = api.requestToken()
> >         print result
> >         print api.getRequestTokenError()
>
> > application = webapp.WSGIApplication([('/settings/linkedin.*',
> > LinkedInSettings)])
>
> > def main():
> >     run_wsgi_app(application)
>
> > if __name__ == "__main__":
> >     main()
>
> > This a request tohttp://localhost:8080/settings/linkedinwill print out:

John OBrien

unread,
Aug 26, 2011, 10:33:34 AM8/26/11
to google-a...@googlegroups.com
I emailed the package maintainer, no response yet. Tito, thanks for letting me know, I was thinking of doing that and so am very appreciative of you sharing that doing so didn't help with the problem.

barnash

unread,
Aug 28, 2011, 1:18:53 AM8/28/11
to Google App Engine
I'm having the same problem, no solution yet.
If you have any update, please post.
Reply all
Reply to author
Forward
0 new messages