Advertisement
ronikuchan

my question on stack overflow

Aug 28th, 2021
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. Hello I have problem about restriction api key google, and the problem :
  2.  
  3. first I use the key restriction with
  4.  
  5. "HTTP referrers (web sites)"
  6.  
  7. like :
  8. 1. mydomain.com/*
  9. 2. star.mydomain.com/star (star *)
  10.  
  11. and when I use api geocode with that restriction it's resulting:
  12.  
  13. > "API keys with referer restrictions cannot be used with this API."
  14.  
  15. and I search the solution I got from this link:
  16. https://stackoverflow.com/questions/42167695/api-key-browser-api-keys-cannot-have-referer-restrictions-when-used-with-this-ap
  17.  
  18. it's said from a person:
  19.  
  20. > "You can change your restriction from a browser restriction to a
  21. > server restriction by using IP addresses to restrict access, instead
  22. > of browser referrers."
  23.  
  24. so I change restrictions from "HTTP referrers (web sites)" to "IP addresses (web servers, cron jobs, etc.)"
  25.  
  26. And resulting this:
  27.  
  28. > "This IP, site or mobile application is not authorized to use this API
  29. > key. Request received from IP address xxx.xxx.xxx.xxx, with referer:
  30. > https://m.mydomain.id/"
  31.  
  32. and I search the solution I got from this link:
  33. https://stackoverflow.com/questions/21933247/this-ip-site-or-mobile-application-is-not-authorized-to-use-this-api-key
  34.  
  35. and it's said by mike20132013 "it requires the server key". And the other person said "There is no such thing as "Server Key" anymore."
  36.  
  37. the other person commnet as:
  38.  
  39. > "Include HTTP header "Referer:yourdomain.com" and this should fix the
  40. > response issues."
  41. > like Here's what I did, and it worked perfectly: var options = { url:
  42. > url, headers:{ Referer:'xxx.herokuapp.com' } }; request.get(options,
  43. > function(...
  44.  
  45. I'm using react-geocode and I don't know to do it
  46.  
  47. and I still confuse to resolve this issue from the second link, can somebody tell me the detail and up to date about this issue???
  48.  
  49. the other solution is use restrictions as none, but i won't do that.
  50.  
  51. other link's but still nothing:
  52. 1. https://stackoverflow.com/questions/23872909/this-site-or-ip-is-not-authorized-to-use-this-api-key
  53.  
  54. take a look this, I had do like this
  55. https://stackblitz.com/edit/react-5bsr3p
  56.  
  57. Thanks for your help....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement