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

2011-08-04 Thread John OBrien
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 = xx
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 = 
SECRET = 
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

-- 
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-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.



Re: [google-appengine] Trouble using the http://code.google.com/p/python-linkedin/

2011-08-04 Thread Chris Copeland
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.comwrote:

 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 = xx
 SECRET = xxx
 RETURN_URL = 
 http://localhost:8080/**settings/linkedin/returnhttp://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 = 
 SECRET = 
 RETURN_URL = 
 http://localhost:8080/**settings/linkedin/returnhttp://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

  --
 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-appengine@googlegroups.com.
 To unsubscribe from this group, send email to
 google-appengine+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/google-appengine?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.