Search code examples
pythongoogle-app-engineopenid

Issue with redirect urls when using Federated Login with AppEngine


I'm trying to use OpenID with AppEngine, and I've setup a simple /_ah/login page for signing in with Google.

But it seems when I use users.create_login_url(dest_url='/some/page?foo=bar&fizz=buzz'), which returns:

https://myapp.appspot.com/_ah/login_redir?claimid=https://www.google.com/accounts/o8/id&continue=https://myapp.appspot.com/some/page?foo=bar&fizz=buzz

when eventually I'm redirected to the dest_url, the second parameter (fizz=buzz) is missing.

Is this a bug/limitation on create_login_url()?


Solution

  • Yes. This is a bug in federated login. Reported here : https://code.google.com/p/googleappengine/issues/detail?id=3249

    Workaround: Escape the ampersand twice

    & -> %26 -> %2526

    url ='/some/page?foo=bar&fizz=buzz'
    import urllib    
    url = urllib.quote(urllib.quote(url_re))
    users.create_login_url(dest_url=url)
    

    or replace the & with %2526.