python - Make calls to Drive API inside of a Google App Engine Cloud Endpoints -
python - Make calls to Drive API inside of a Google App Engine Cloud Endpoints -
i trying build own endpoints within of app engine application. there endpoint api needs inquire user "https://www.googleapis.com/auth/drive.readonly" scope. performs list of drive api , scan drive file of user.
the problem don't know how create phone call drive api within of endpoint api.
i think within of endpoint method, has credentials got user. don't know how receive that.
i using python backend language.
@drivetosp_test_api.api_class(resource_name='report') class report(remote.service): @endpoints.method(emptymessage, emptymessage, name='generate', path='report/generate', http_method='get' ) def report_generate(self, request): logging.info(endpoints) homecoming emptymessage()
you can utilize os.environ
access http authorization header, includes access token, granted scopes asked on client side, include drive.readonly
in sample.
if "http_authorization" in os.environ: (tokentype, token) = os.environ["http_authorization"].split(" ")
you can utilize token create calls api, either straight or using google apis client library python:
credentials = accesstokencredentials(token, 'my-user-agent/1.0') http = httplib2.http() http = credentials.authorize(http) service = build('drive', 'v2', http=http) files = service.files().list().execute()
note approach won't work if using android client, because uses id-token authorization instead of access tokens.
python google-app-engine google-cloud-endpoints credentials google-drive-sdk
Comments
Post a Comment