Skip to content

Instantly share code, notes, and snippets.

@landonf
Created May 26, 2009 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save landonf/118238 to your computer and use it in GitHub Desktop.
Save landonf/118238 to your computer and use it in GitHub Desktop.
A simple appengine-based facebook request signer
from google.appengine.ext import webapp
import md5
# XXX Facebook private application key
APP_KEY = "AAAAAAAAAAAAAAAAAAAAAAAAA"
class FacebookRequestSigner(webapp.RequestHandler):
def get(self):
method = self.request.get("method")
# Only sign createToken/getSession requests
if (method != "auth.getSession" and method != "auth.createToken"):
self.error(401)
self.response.out.write("Can not sign method %s" % method)
return
# Compute the signature
canonical = ""
for key in sorted(self.request.arguments()):
canonical += "%s=%s" % (key, self.request.get(key))
canonical += APP_KEY
digest = md5.new(canonical.encode("utf-8"))
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write(digest.hexdigest())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment