GlobalFishingWatch / gfwr

R package for accessing data from Global Fishing Watch APIs
https://globalfishingwatch.github.io/gfwr/
Apache License 2.0
59 stars 7 forks source link

Authorization error when trying to run get_raster #34

Closed gmcdonald-sfg closed 2 years ago

gmcdonald-sfg commented 2 years ago

When following the README.md instructions, I get an authorization error when trying to run get_raster. I do not get this error when using the other get_* functions - get_vessel_info, get_event work correctly.

Following your instructions, and after saving my authorization token to .Renviron, when I run this:

library(gfwr)

key <- Sys.getenv("GFW_TOKEN")

shape_json = '{"geojson":{"type":"Polygon","coordinates":[[[-76.11328125,-26.273714024406416],[-76.201171875,-26.980828590472093],[-76.376953125,-27.527758206861883],[-76.81640625,-28.30438068296276],[-77.255859375,-28.767659105691244],[-77.87109375,-29.152161283318918],[-78.486328125,-29.45873118535532],[-79.189453125,-29.61167011519739],[-79.892578125,-29.6880527498568],[-80.595703125,-29.61167011519739],[-81.5625,-29.382175075145277],[-82.177734375,-29.07537517955835],[-82.705078125,-28.6905876542507],[-83.232421875,-28.071980301779845],[-83.49609375,-27.683528083787756],[-83.759765625,-26.980828590472093],[-83.84765625,-26.35249785815401],[-83.759765625,-25.64152637306576],[-83.583984375,-25.16517336866393],[-83.232421875,-24.447149589730827],[-82.705078125,-23.966175871265037],[-82.177734375,-23.483400654325635],[-81.5625,-23.241346102386117],[-80.859375,-22.998851594142906],[-80.15625,-22.917922936146027],[-79.453125,-22.998851594142906],[-78.662109375,-23.1605633090483],[-78.134765625,-23.40276490540795],[-77.431640625,-23.885837699861995],[-76.9921875,-24.28702686537642],[-76.552734375,-24.846565348219727],[-76.2890625,-25.48295117535531],[-76.11328125,-26.273714024406416]]]}}'

get_raster(spatial_resolution = 'low',
           temporal_resolution = 'yearly',
           group_by = 'flag',
           date_range = '2020-01-01,2021-10-01',
           shape_json = shape_json,
           key = key)

Returns:

Error in `resp_abort()`:
! HTTP 401 Unauthorized.

I get this same error when trying to run the other get_raster examples.

natemiller commented 2 years ago

thanks @gmcdonald-sfg . I suspect something has been broken on the API side as the engineers continue developing. I'll have a look and see if we need to change the endpoint.

natemiller commented 2 years ago

@gmcdonald-sfg I have just tried to run the code you shared above and it seems to have worked for me. Can you try once again? Perhaps something that was broken on the API side has been fixed?

shinnakayama commented 2 years ago

I get the exact same error.

natemiller commented 2 years ago

@shinnakayama @gmcdonald-sfg Can you please try to install the package again and rerun the get_raster function? I have updated the base endpoint so that it works with the public API tokens. Addressed with PR #39

If it is now fixed can you please close the issue or provide feedback it the problem remains

gmcdonald-sfg commented 2 years ago

It's now working, thank you @natemiller!