I have a Python script in Google App Engine that just gives a simple welcome message to the user. If the user is logged into Google then there is a personalized welcome message with the code:
if users.get_current_user():
self.response.out.write('Welcome ' + users.get_current_user()')
What I want to do is if the user is not already logged in, have a button that can be pressed which will redirect them to the Google login page to login to their account.
else:
#redirect user to login page here
I have tried some ways to do this but no of them will work. I have tried:
self.response.out.write('<form action="%s">
<input type="submit" value="Login to Google"></form>
' % users.create_login_url('/')
When the button is pressed nothing happens so I tried:
self.response.out.write('<form action="%s">
<input type="submit" value="Login to Google"></form>
' % self.redirect(users.create_login_url('/'))
This just redirects the user to the login page as soon as the main page is visited.
Is there any way to redirect the user to the Google login page when a button is pressed?