Skip Navigation

[Resolved] Toolset Maps saying to use httpreferrer and not to use it at the same time.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 14 replies, has 3 voices.

Last updated by Luo Yang 1 year, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2560487

Tell us what you are trying to do? I am trying to configure Google Maps API with Toolset Maps

Is there any documentation that you are following? https://toolset.com/course-lesson/creating-a-maps-api-key/

Is there a similar example that we can see? In development, but can give access if needed.

What is the link to your site? hidden link

My Issue:
I have generated a Google Maps API Key that has access to all maps related APIs included the 3 required: Maps JavaScript API, Geocoding API, and Places API.

API key was originally restricted using httpreferrers(website), but when trying that way /wp-admin/admin.php?page=toolset-settings > maps throws error of: REQUEST_DENIED - API keys with referer restrictions cannot be used with this API. when using the "Check API" button.

So then I switched to IP restriction and it passed checking API.

The map preview on Map Styles would not load though and console says: Google Maps JavaScript API error: RefererNotAllowedMapError

So toolset is telling me I can't use httpreferrer and then it's telling me I have to.

Any help is appreciated.

#2560879

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

While adding the restriction to the Google Maps API key, there is some important information that needs to be considered.

If you'll go to WP Admin -> Toolset -> Settings -> Maps, you'll see that there are two fields to enter Google Map API keys.

When only the main/primary key is added, it is used for both the client-side and the server-side requests.

The key with domain restriction works for the client-side requests, but not for the server-side ones. To overcome this limitation, the second optional key field was introduced.

When you'll include a second optional key, that will be used for the server-side requests, allowing you to use a primary key with the domain restriction turned on.

If your hosting server has a static IP, you can optionally enable IP restrictions on the second key too, but it is not necessary, since this second key for the server-side requests is not publically exposed.

I hope this explanation helps and please let me know if you have any follow-up questions.

regards,
Waqar

#2560973

So you're telling me the optional field is actually required?

#2560975

I don't care if I use domain restriction on the primary or IP restriction, but some kind of restriction is needed.

#2560977

I have kept domain restriction on the primary API key and created a second API key with IP restriction.
It does pass when using "Check API" button, but Map Styles preview still won't load and console still says Google Maps JavaScript API error: RefererNotAllowedMapError

#2562139

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

> So you're telling me the optional field is actually required?

- The second API key becomes essential only when the Google Maps API key with some type of restriction is in use.

> I have kept domain restriction on the primary API key and created a second API key with IP restriction.
It does pass when using "Check API" button, but Map Styles preview still won't load and console still says Google Maps JavaScript API error: RefererNotAllowedMapError

- The "RefererNotAllowedMapError" error suggests that "Application restrictions" is enabled in your Google Maps API key settings with "HTTP referrers (web sites)" option.
( ref: hidden link )

Can you try switching to domain restriction and please ensure that your website's domain is added, in a way that allows all sub-domains and paths?
( example: *.abc.com/* )

You'll find some useful suggestions on troubleshooting "HTTP referrers" restriction in this thread too:
https://stackoverflow.com/questions/35288250/google-maps-javascript-api-referernotallowedmaperror

#2565455

I'm a little confused. First you said to put IP restriction on second API key and now you are saying to put domain restriction on.

So now I've done what you said and changed second IP to domain restriction and we're back to the original error: REQUEST_DENIED - API keys with referer restrictions cannot be used with this API.

All this back and forth has me thinking we might want to loop someone else in that might have more experience.

#2567067

Hi, I hope you are well. I'm just following up on this.

#2567359

Hello,

Waqar is on vacation, I will take care of this ticket.

Can you share your development website credentials in below private message box, also point out the problem page URL:
Where I can see the error message:

but Map Styles preview still won't load and console still says Google Maps JavaScript API error: RefererNotAllowedMapError

#2568969

Thanks for the details.

The problem is in the second Google Map API key.
You can add a key with restrictions (URL referrer restrictions) as the first key, and an unrestricted key as the second Google map API key.

Please follow our document to setup the second:
https://toolset.com/course-lesson/creating-a-maps-api-key/#known-issues

this second key is used exclusively for server-side requests. This means it is never exposed in HTML and does not need restrictions. If you want extra security, you can restrict it, but only by IP addresses, not by domains.

#2573733

I have to say all this back and forth and changing what you are telling me to do is getting very frustrating. I've not set up API key 1 with domain restriction and API key 2 with no restrictions. Check API button works, but still no map and JS error in console reads:

js?libraries=places&v=3&key=AIzaSyB7lKbGvO4l2oajB9OZOCyMCpdtpsWV5Xs:92 Google Maps JavaScript API error: RefererNotAllowedMapError
hidden link
Your site URL to be authorized: hidden link

API key 1 restriction is *blueforkliftjobs.com/*

Can we please actually get a working answer for this soon. In 1 week we'll have been trying to get this to work for a month...

#2573735

Now even getting further console errors:

Loading the Google Maps JavaScript API without a callback is not supported: hidden link

#2573933

Please check the credentials you provided above:
https://toolset.com/forums/topic/toolset-maps-saying-to-use-httpreferrer-and-not-to-use-it-at-the-same-time/#post-2568713

I have tried it again, but get below error message:
Error: The username mike is not registered on this site.

#2577039

So the keys were different when I logged back in. Once I updated keys again it worked. Now though I'm having another issue. When I'm in a view and there are no maps options like distance in the filters. How do I get those? Thank You for telling publicly the private admin name I messaged you. That is not cool. It's back on the site now though.

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/when-im-in-a-view-and-there-are-no-maps-options-like-distance-in-the-filters/

#2577471

I assume the original issue of this thread is resolved, according to our support policy, we prefer one ticket one question.
For your other new issues, please check the new thread here:
https://toolset.com/forums/topic/when-im-in-a-view-and-there-are-no-maps-options-like-distance-in-the-filters/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.