title: Just check for user's Google organization in JavaScript and then display content?
body: <p>I'm trying to figure out how to use Google's API service, and I have a client and API key for Google OAuth. Specifically, though I want to check a user's organization, and then echo out some info for them. I understand that that info will be visible with a simple CTRL-SHIFT-I or CTRL-U, but that doesn't matter to me right now. Thanks for your help in advance (JavaScript because I want to try to host this on GitHub pages)!</p>
  
  <p>Here's a Google example I've tried, and I just get error 400's (client and API keys have been deleted).</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// Enter an API key from the Google API Console:
  //   https://console.developers.google.com/apis/credentials
  var apiKey = 'AIzaSyDyyNLwHpVqy88tRamPt1NbyVWFzYkLuhA';
  // Enter the API Discovery Docs that describes the APIs you want to
  // access. In this example, we are accessing the People API, so we load
  // Discovery Doc found here: https://developers.google.com/people/api/rest/
  var discoveryDocs = ["https://people.googleapis.com/$discovery/rest?version=v1"];
  // Enter a client ID for a web application from the Google API Console:
  //   https://console.developers.google.com/apis/credentials?project=_
  // In your API Console project, add a JavaScript origin that corresponds
  //   to the domain where you will be running the script .apps.googleusercontent.com.
  var clientId = '873243932753-jfebiqi1ja0b9a2jiqdiirb8vtjlk4n9.apps.googleusercontent.com.apps.googleusercontent.com';
  // Enter one or more authorization scopes. Refer to the documentation for
  // the API or https://developers.google.com/people/v1/how-tos/authorizing
  // for details.
  var scopes = 'profile';
  var authorizeButton = document.getElementById('authorize-button');
  var signoutButton = document.getElementById('signout-button');
  
  function handleClientLoad() {
    // Load the API client and auth2 library
    gapi.load('client:auth2', initClient);
  }
  
  function initClient() {
    gapi.client.init({
      apiKey: apiKey,
      discoveryDocs: discoveryDocs,
      clientId: clientId,
      scope: scopes
    }).then(function() {
      // Listen for sign-in state changes.
      gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
      // Handle the initial sign-in state.
      updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
      authorizeButton.onclick = handleAuthClick;
      signoutButton.onclick = handleSignoutClick;
    });
  }
  
  function updateSigninStatus(isSignedIn) {
    if (isSignedIn) {
      authorizeButton.style.display = 'none';
      signoutButton.style.display = 'block';
      makeApiCall();
    } else {
      authorizeButton.style.display = 'block';
      signoutButton.style.display = 'none';
    }
  }
  
  function handleAuthClick(event) {
    gapi.auth2.getAuthInstance().signIn();
  }
  
  function handleSignoutClick(event) {
    gapi.auth2.getAuthInstance().signOut();
  }
  // Load the API and make an API call.  Display the results on the screen.
  function makeApiCall() {
    gapi.client.people.people.get({
      'resourceName': 'people/me',
      'requestMask.includeField': 'person.names'
    }).then(function(resp) {
      var p = document.createElement('p');
      var name = resp.result.names[0].givenName;
      p.appendChild(document.createTextNode('Hello, ' + name + '!'));
      document.getElementById('content').appendChild(p);
    });
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p&gt;Say hello using the People API.&lt;/p&gt;
  
  &lt;!--Add buttons to initiate auth sequence and sign out--&gt;
  &lt;button id="authorize-button"&gt;Authorize&lt;/button&gt;
  &lt;button id="signout-button"&gt;Sign Out&lt;/button&gt;
  
  &lt;div id="content"&gt;&lt;/div&gt;
  
  &lt;script async defer src="https://apis.google.com/js/api.js" onload="this.onload=function(){};handleClientLoad()" onreadystatechange="if (this.readyState === 'complete') this.onload()"&gt;
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Edit: I found out that this needs to be done with <strong>Admin SDK</strong>. Still a bit confused on how to do this though.</p>