如何使用OAuth从Python应用程序访问Google应用程序引擎端点API?

如何使用OAuth从Python应用程序访问Google应用程序引擎端点API?,python,google-app-engine,google-oauth,google-cloud-endpoints,google-cloud-platform,Python,Google App Engine,Google Oauth,Google Cloud Endpoints,Google Cloud Platform,如何访问用于Python(而不是web、android和ios)的Google应用程序引擎端点API 我读过这篇文章,但它没有足够的解释来理解这一点 正如我在服务端发现的,我可以使用这样的代码来识别用户: @endpoints.method(message_types.VoidMessage, Greeting, path='hellogreeting/authed', http_method='POST', name='g

如何访问用于Python(而不是web、android和ios)的Google应用程序引擎端点API

我读过这篇文章,但它没有足够的解释来理解这一点

正如我在服务端发现的,我可以使用这样的代码来识别用户:

@endpoints.method(message_types.VoidMessage, Greeting,
                  path='hellogreeting/authed', http_method='POST',
                  name='greetings.authed')
def greeting_authed(self, request):
    current_user = endpoints.get_current_user()
    email = (current_user.email() if current_user is not None
             else 'Anonymous')
    return Greeting(message='hello %s' % (email,))

如何从Python客户端连接到此API,并使用身份验证调用“hellogreeting/authed”
当前用户!=无

你能分享一些代码吗

app_id = 'xxx'
user = 'xxx'
password = 'xxx'
callAPI(app_id, user, password, 'hellogreeting/authed')

您需要配置应用程序引擎实例,以便能够为您的API提供服务。我建议您为您的API创建一个单独的模块,如以下文档中所述:

一旦在服务器端正确设置了所有内容,您就可以使用如下方式调用API:
http://your-module.your-app.appspot.com/_ah/spi/hellogreeting/authed

如果您使用的是开发服务器,那么访问模块的方式就有点不同,但是一旦您知道App Engine开发服务器为您的API模块分配了哪个端口号,您就可以使用:
http://localost:/_ah/spi/hellogreeting/authed

希望这有帮助