2

I'm working on cross platform application. navigator.geolocation was working fine, but since last 2 days it just giving problem in Google chrome. Is the api deprecated or some other issue for this api? I tested following code on many different browsers and network but still the same issue.

var options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0
};

function success(pos) {
  var crd = pos.coords;

  console.log('Your current position is:');
  console.log('Latitude : ' + crd.latitude);
  console.log('Longitude: ' + crd.longitude);
  console.log('More or less ' + crd.accuracy + ' meters.');
};

function error(err) {
  console.warn('ERROR(' + err.code + '): ' + err.message);
};

navigator.geolocation.getCurrentPosition(success, error, options);

ERROR(2): Network location provider at 'https://www.googleapis.com/' : Returned error code 403.

Bilal Akmal
  • 31
  • 1
  • 2
  • 4
  • http://www.googleapis.com doesn't exist. https://ajax.googleapis.com does. Are you trying [to use one of these libraries](https://developers.google.com/speed/libraries/)? – Andy Sep 01 '15 at 11:47
  • Do you also get ... `getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details.` – Jaromanda X Sep 01 '15 at 11:52
  • I'm having the same issue. Chrome 44 on OS X latest. I've received the insecure deprecation warning on external sites, but no such warning when running locally (via file:// protocol or localhost). Same 403 error, same message. – SquareFeet Sep 01 '15 at 11:56
  • No, it just giving me one error: ERROR(2): Network location provider at 'https://www.googleapis.com/' : Returned error code 403. – Bilal Akmal Sep 01 '15 at 11:57
  • Yeah, I think that might be the issue. 2 months ago chrome 43 also changes some api's, that caused problems in scrolling in sencha touch. – Bilal Akmal Sep 01 '15 at 12:00
  • The problem is down to authenticating with the Google geolocation API. Some help can be found here: http://onefinepub.com/2015/04/fix-chromium-network-location-provider-returning-error-code-403/ – Yehia Sep 01 '15 at 12:11

2 Answers2

1

Latest chrome has deprecated this API on non-secure origins:

https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins

Time to get https://localhost up and running ;)

For future queries... https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only?hl=en

Safal Pillai
  • 1,567
  • 1
  • 16
  • 31
danp
  • 14,876
  • 6
  • 42
  • 48
  • 1
    I don't think so this, this also fails for me on localhost which is defined as a secured domain. – Ido.Co Sep 01 '15 at 17:43
1

This appears to be fixed now. Must have been an issue due to a server-side change google made. When I was debugging I was seeing a rate limit issue, even when I ran the getCurrentPosition() call in console on https://www.google.com.