

def post(self):
    access_token = self.request.get('x_access_token')
    provider = self.request.get('x_provider')
    if ((provider not in self.PROVIDERS) or (access_token is None)):
        self.abort(401, 'Unknown provider or access token')
    auth_info = {
        'access_token': access_token,
    }
    fetch_user_info = getattr(self, ('_get_%s_user_info' % provider))
    user_info = fetch_user_info(auth_info)
    if ('id' in user_info):
        user = self._on_signin(user_info, auth_info, provider)
        token = user.create_bearer_token(user.get_id())
        self.response.content_type = 'application/json'
        self.response.body = json.dumps({
            'access_token': token.token,
            'token_type': 'Bearer',
            'expires_in': token.bearer_token_timedelta.total_seconds(),
            'refresh_token': token.refresh_token,
        })
    else:
        self.abort(401, 'Access token is invalid')

dataset/ETHPy150Open loudnate/appengine-endpoints-auth-example/auth/handlers.py AuthHandler.post/original