简体   繁体   中英

google sheets api from AWS Lambda

I'm trying a simple google sheets api code done in JAVA and run it from AWS Lambda function and I got a timeout error like this

2018-04-20 01:55:01.573:INFO::Started SocketConnector@localhost:35315 Please open the following address in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=523391452358-5o611gt4igv3nik2blim3kr3q2m690sl.apps.googleusercontent.com&redirect_uri=http://localhost:35315/Callback&response_type=code&scope=https://www.googleapis.com/auth/spreadsheets.readonly END RequestId: d495a239-443d-11e8-9619-bd212b7bbf47 REPORT RequestId: d495a239-443d-11e8-9619-bd212b7bbf47 Duration: 60046.56 ms Billed Duration: 60000 ms Memory Size: 128 MB Max Memory Used: 48 MB
2018-04-20T01:55:58.627Z d495a239-443d-11e8-9619-bd212b7bbf47 Task timed out after 60.05 seconds

It seems like Google SDK wants to open the browser for the user to authenticate, but there's no browser in AWS Lambda. Is there another way to authenticate without opening the browser? If i use https://developers.google.com/identity/protocols/OAuth2ServiceAccount#jwt-auth will it work?Anyone has any helpful links/ sample that I can use? I'm not experience programmer really appreciate your help, thank you in advance.

You can use a service account key in order to avoid using a browser.

A service account is a special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM