title: Google OAuth2 Sign-in with AngularJS callback
body: <p>For reference, here is the Google+ flow that I am working with:</p>
  
  <p><a href="https://developers.google.com/+/web/signin/server-side-flow">https://developers.google.com/+/web/signin/server-side-flow</a></p>
  
  <blockquote>
    <ol>
    <li>User clicks the sign-in button. The authorization request is sent to Google's OAuth servers</li>
    <li>OAuth dialog is triggered for the user</li>
    <li>access_token, id_token, and a one-time code are returned</li>
    <li>Client sends id_token and code to server</li>
    <li>Server exchanges one-time code for access_token</li>
    <li>Google returns access_token</li>
    <li>Server should confirm "fully logged in" to Client</li>
    </ol>
  </blockquote>
  
  <p>I already have this mostly working, but I would like AngularJS to know when the client is "fully logged in" at step 7.</p>
  
  <p>Ideally, I would like step 3 to be handled by an AngularJS Controller, but I'm not sure if that's possible.</p>
  
  <p>The sign-in button is here:</p>
  
  <p><a href="https://developers.google.com/+/web/signin/server-side-flow#step_4_add_the_sign-in_button_to_your_page">https://developers.google.com/+/web/signin/server-side-flow#step_4_add_the_sign-in_button_to_your_page</a></p>
  
  <pre><code>&lt;!-- Add where you want your sign-in button to render --&gt;
  &lt;div id="signinButton"&gt;
    &lt;span class="g-signin"
      data-scope="https://www.googleapis.com/auth/plus.login"
      data-clientid="YOUR_CLIENT_ID"
      data-redirecturi="postmessage"
      data-accesstype="offline"
      data-cookiepolicy="single_host_origin"
      data-callback="signInCallback"&gt;
    &lt;/span&gt;
  &lt;/div&gt;
  &lt;div id="result"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The data-callback parameter allows me to specify a function, but I can only get it to work on global functions.</p>
  
  <p>The only work-around I can think of is for AngularJS to constantly poll the server for updates just in case a user logs in, but I was wondering if there was a way to make this work within the event structure so that it's all instant.</p>
  
  <p>Whether this is possible or not, I would greatly appreciate any advice on how I should go about this. Please let me know if you have any questions. Thank You!</p>