简体   繁体   中英

Google Earth Engine REST API Authentication from Ruby fails

I'm trying to use a service account to make an API request to https://earthengine.googleapis.com/v1alpha/projects/{my-project}:listAssets?key={serviceKey} , but I always get 401 unauthorized.

 url = "https://earthengine.googleapis.com/v1alpha/projects/{project-id}:listAssets?key=ServiceAccountKey"
endpoint = URI.parse(url)
request = Net::HTTP::Get.new(endpoint.to_s)

response = Net::HTTP.start(endpoint.host, endpoint.port, use_ssl: true) { |http| http.request(request) }
JSON.parse(response.body)

I got the same issue in the past. You need to be accepted/enrolled first by the Google EarthEngine team in order to access the API.

Signup for Earth Engine. Once you have been accepted, you will receive an email with additional information.

To signup, follow instructions from the official Google docs here .

It took 1 day in my case and I could then call the API smoothly.

EDIT: The HTTP 401 response you are getting indicates invalid authentication credentials. In my case, the app connects using a Service Account. I followed instructions here and my app could connect smoothly to the Earth Engine. hope it helps

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