Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Lookup doesn't work with fix? #3

Closed
evanwarner opened this issue Jan 6, 2019 · 11 comments
Closed

Address Lookup doesn't work with fix? #3

evanwarner opened this issue Jan 6, 2019 · 11 comments

Comments

@evanwarner
Copy link

Everything seems to be working with this fix except Address Lookup. None of my images are receiving the gray suggested IPTC locations, and the Address Lookup indicator is stuck at "Looking up N locations." My Google Cloud console is showing about 30% of the Geocoding API requests are triggering 403 errors (which may or may not be related since it's not 100% errors).

I poked around a few of the other .lua files but didn't see any other API calls to update.

Anyone else experiencing this?

@astuder
Copy link
Owner

astuder commented Jan 6, 2019

You may run in to the 50 requests / second limit described here:
https://developers.google.com/maps/documentation/geocoding/usage-and-billing
Are you trying to do bulk operations? In my own use, I only do manual geo-tagging.

@evanwarner
Copy link
Author

Not that much bulk. I import tracklogs from photoshoots then autotag photos on that. The one I ran after this fix had ~40 photos in it. I don't think I'm hitting the 50/s limit as the cloud console is showing < 20 hits from this last attempt (but it was 100% 403 errors).

@astuder
Copy link
Owner

astuder commented Jan 7, 2019

Does the map show you a place name at the top right? I think that would use same API.

I think the troublesome API is:
https://developers.google.com/maps/documentation/geocoding/start#reverse

On the Usage and Billing page, they mention "keyless access" which was deprecated. I wonder if there are some of these calls in the Lightroom module. Though not sure how that would still show up in your Cloud Console.
https://developers.google.com/maps/documentation/geocoding/usage-and-billing

If there's a string starting with "https://maps.googleapis.com/maps/api/geocode/json?" but no key, you could try to patch that by inserting your key as URL parameter.

@evanwarner
Copy link
Author

Yep, the location at upper right displays correctly and changes as I pan around the map. Console shows a spike in successful geocoding hits after I do that.

I'm beginning to think this is not an API error and that Lightroom is for some reason not even triggering the lookup.

@astuder
Copy link
Owner

astuder commented Jan 13, 2019

Warning: I haven't tried this myself.

The files LOCATIONMAPVIEW.LUA and REVERSEGEOCODESERVICEFALLBACK.LUA make heavy use of the JavaScript APIs. As part of that, they include HTML code that loads JavaScript libraries from Google. The documentation by Google says to include the API key when loading these libraries.
https://developers.google.com/maps/documentation/javascript/get-api-key

So, you could try to replace this string:
http://maps.google.com/maps/api/js?sensor=false
with
https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false

Definitely make a backup of your Location.lrmodule before trying that.

@evanwarner
Copy link
Author

evanwarner commented Jan 15, 2019

Ok, I think I found the culprit. By examining (using Charles) the network call made by Lightroom when I drop a photo onto the map, I found this error:
Unable to authenticate the request. The 'signature' parameter is not required. Learn more: https://developers.google.com/maps/documentation/business/webservices/auth

The full API call URI was:
/maps/api/geocode/json?key=[my-key]&language=EN&channel=lightroom-6.14&latlng=[coordinates-of-my-photo]&signature=[string-of-characters]

If I recompose that request in Charles and remove the signature parameter, I get a successful JSON response.

However, I cannot figure out where in the code that parameter is being attached. I ran a search on every file inside Lightroom.app and couldn't find the signature value. I couldn't even find an instance of the word "signature" in the Location.agmodule package. Perhaps it's obfuscated somewhere else?

Update:
After some additional tinkering I can say that the call is originating from AgReverseGeocodeService.lua (removing and re-adding the obsolete sensor=false parameter in there causes the failing call in Charles to also reflect that change.)

@astuder
Copy link
Owner

astuder commented Jan 15, 2019

Just came here to say, that it's most likely the URL in AgReverseGeocodeService.lua.

I see the format string for "latlang"
%s&latlng=%f,%f
The %s at the beginning will be replaced with the URL string that we patched.

But I can't find "signature" in any of the files. Probably obfuscated for security reasons, or might be calculated from the LR license key. ok, I should read your full post before thinking :-)

There's sig, followed by nature, = and & in LocationDebugPanel.lua. You could try to see whether the signature variable name changes by replacing nature with something else. If yes, and we're lucky, Google may simply ignore the unknown variable name.

@evanwarner
Copy link
Author

@astuder BRAVO!!! That indeed is the spot. I used your Python script to change nature to something else. Charles reflects that change in the URI and Lightroom's address lookup is instantly up and running again.

@astuder astuder mentioned this issue Jan 15, 2019
@rs38
Copy link

rs38 commented Jan 27, 2019

where can I see the javascript console that LR mentions in the error message for debugging???

@astuder
Copy link
Owner

astuder commented Jan 27, 2019

@rs38 I wondered as well when I started looking into how to fix the maps, but I haven't figured out how to get to the javascript consolte.

@tkopley
Copy link

tkopley commented Dec 29, 2019

Many thanks astuder for a nice fix. I just tried the Map module in Lightroom 6.14 for the first time in well over a year, got the surprising (for me) map load error, found a Lightroom users forum on the topic with a link to your repository, and easily got it working again following your instructions (and setting up all the Google Cloud prerequisites). This is on a Mac running 10.14.6 (Mojave). I am not an IT professional, so I'm happy it all worked out. If anything goes wrong, I'll be sure to check out some of the other issues people have brought up here. Great resource for sure. Thanks again astuder and everyone for their contributions.

@astuder astuder closed this as completed Dec 29, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants