0

I tried to run the sample given here on my web server which is Google App Engine server.

I modified the clientId and apiKey with clientId and clientSecret from my google cloud console.

When I run, I see in javascript console a 400 Bad Request for

https://content.googleapis.com/discovery/v1/apis/plus/v1/rpc?fields=methods%2F*%2Fid&pp=0&key=TO6faADFEmHdfdh08mm8XgR

Please guide me.

2 Answers 2

1

As far as I can tell, the sample is working on the server you linked. As Ian mentioned, the sample you are running looks a little outdated, the JavaScript Quickstart is the latest and greatest and uses the Google+ Sign-In button which has a number of enhancements, particularly when you are using client-side authorization.

To test that your sample is working, you can open the Chrome developer tools and run some simple client library code such as:

gapi.client.plus.activities.list(
  {userId: 'me'}).execute(
    function(resp){
      console.log(resp);
    });

If you see your activity feed, everything is working.

Regarding locally ... In order for the JavaScript library to work, you also must be running a web server on your computer such as the Python Simple HTTP Server:

python -m SimpleHTTPServer 8000

or Apache, twistd, etc.

If you directly open the file, permissions will prevent the library from working.

Your authorized JavaScript origins must also match the port (and protocol, e.g. https/http) that are set up in your Google APIs console project. If it's working remotely but not locally, you might be missing a localhost origin.

Sign up to request clarification or add additional context in comments.

1 Comment

By "locally" i mean on a local server. I was using GAE. And it didn't work
1

That is a pretty old sample! Try https://developers.google.com/+/quickstart/javascript for a newer one.

With regards to this problem: don't put your client secret in the key field! The client secret should never be put into public, it should only ever be used on a server where it can be kept private. The API key in this case is a separate entry (the simple API access browser key).

More about API keys: https://developers.google.com/console/help/#generatingdevkeys

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.