whitelist this origin for your project's client ID google api code example
Example: https://console.developers.google.com/ and whitelist this origin for your project's client ID.
if you are testing locally, use http://localhost:8080 (or whatever port you are using) for both whitlisting at https://console.developers.google.com/apis/credentials and on your browser (not http://127.0.0.1:8080) .this worked for me