Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9222643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:52:51+00:00 2026-06-18T03:52:51+00:00

I want to restrict login to a python application running on Google App Engine

  • 0

I want to restrict login to a python application running on Google App Engine to members of a particular Google Apps Domain using OpenID.

According to the thread How limit Google Federated Login to specific Apps domain?
this could be accomplished by simply substitution the ordinary google openid autentication url

https://www.google.com/accounts/o8/id

with

https://google.com/accounts/o8/site-xrds?hd=example.com

This does however not seem to work using users.create_login_url() in GAE for Python. It throws a 500 server error that is not shown in the google app engine log (the log only shows the redirect and the “OpenID” from logging.debug).

Does anyone have any suggestions on how to fix this?

app.yaml

application: example
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /_ah/login_required
  script: main.app

- url: .*
  script: main.app
  login: required

main.py:

import webapp2, logging
from google.appengine.api import users

# Any google account, works like a charm
#federated_identity='https://www.google.com/accounts/o8/id'

# only accounts under spefific domain, does not work
federated_identity='https://google.com/accounts/o8/site-xrds?hd=example.com'

dest_url = 'http://example.appspot.com/'

class Main(webapp2.RequestHandler):
    def get(self):
        logging.debug('Main')
        user = users.get_current_user()
        if user:
            self.response.out.write('Hello %s<p>[<a href="%s">log out</a>]' %  (user.email(),
                    users.create_logout_url(self.request.uri)))
        else:
            self.response.out.write('Not logged in')

class OpenID(webapp2.RequestHandler):
    def get(self):
        logging.debug('OpenID')
        login_url = users.create_login_url(dest_url=dest_url,
            federated_identity=federated_identity)
        self.redirect(login_url)

app = webapp2.WSGIApplication([
    ('/_ah/login_required', OpenID),
    ('/', Main)
], debug=True)

Update
Sebastian suggests that a solution might be to url encode the federated identity. I tried url encoding the whole url or only the question mark as suggested. Unfortunately this does not change anything.
The redirect urls as shown in the browser address bar or if written to log:

No url encoding:
http://example.appspot.com/_ah/login_redir?claimid=https://google.com/accounts/o8/site-xrds?hd=example.com&continue=http://example.appspot.com/

With url encoding:
http://example.appspot.com/_ah/login_redir?claimid=https%3A%2F%2Fgoogle.com%2Faccounts%2Fo8%2Fsite-xrds%3Fhd%3Dexample.com&continue=http://example.appspot.com/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:52:53+00:00Added an answer on June 18, 2026 at 3:52 am

    I think (I haven’t tested this myself) that the issue is because the federated_identity is not encoded. Try replacing the question mark with %3F. Also make sure the url

    https://google.com/accounts/o8/site-xrds?hd=example.com
    

    works.

    The test I did was to go to the url

    http://testsk2012.appspot.com/_ah/login_redir?claimid=https://www.google.com/accounts/o8/site-xrds%3Fhd=somesite.com&continue=http://testsk2012.appspot.com/
    

    and it succeeded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to restrict my web app so that .txt files can not be
We have a server application that we want to restrict non-users from triggerring it
I am working in Asp.net and I want to restrict the user while login,
I have a cics application and i don't want to develop an login screen,
I want to restrict input to match the statement change = where word and
I want to restrict the number of fractional decimal places of a number to
i want to restrict the number of item selection from the listbox in asp.net
If I have a model with a ManyToManyField and I want to restrict it
SQL Server 2008 Profiler always profiles all databases. I want to restrict profiling or
Im working on a website (html,css,javascript, ajax, php,mysql), and I want to restrict the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.