I have an App Engine application that currently enforces authentication via the login: admin parameter in the route handlers in the application's app.yaml file. According to the app.yaml documentation, when setting a login value of anything other than optional:
...the handler first checks whether the user has signed in to the application using its authentication option. If not, by default, the user is redirected to the sign-in page.
This works fine for accessing the app through the GUI, as the user simply follows the redirect, signs in with his/her Google credentials and gets redirected back to the app.
But one of the app's integration tests makes a HTTP GET to one of the application's endpoints and asserts on the response. Because the login: admin setting redirects the request to the sign-in page, the assertion fails as it hasn't been authenticated.
As described in the docs:
Once the user has signed in or created a Google account, the user is redirected back to your application.
My question is: how can I programmatically sign in to my Google account in my test code once the app has redirected the request to the sign-in page? Presumably, once this is done, the now-authenticated request will be redirected back to the app and all will be well.
UPDATE:
I came across this related post, but the accepted answer is from 2008 and uses Google's now-defunct ClientLogin API. One of the other answers mentions using Google's OAuth support, but it isn't clear to me how I would use it for this case.