title: Exchanging a google idToken for local openId token c#
body: <p>I am using this github project <a href="https://github.com/openiddict/openiddict-core" rel="nofollow noreferrer">https://github.com/openiddict/openiddict-core</a>  which is great. But I am stuck as to what the procedures should be, or how to implement them, when the user uses an external identity provider, for this example, I will use google.</p>
  
  <p>I have an angular2 app running, with an aspnet core webAPI.  All my local logins work perfectly, I call <code>connect/token</code> with a username and password, and an accessToken is returned.</p>
  
  <p>Now I need to implement google as an external identity provider. I have followed all the steps <a href="https://developers.google.com/identity/sign-in/web/sign-in" rel="nofollow noreferrer">here</a> to implement a google login button. This opens a popup when the user logins in. This is the code I have created for my google button.</p>
  
  <pre><code>// Angular hook that allows for interaction with elements inserted by the
  // rendering of a view.
  ngAfterViewInit() {
      // check if the google client id is in the pages meta tags
      if (document.querySelector("meta[name='google-signin-client_id']")) {
          // Converts the Google login button stub to an actual button.
          gapi.signin2.render(
              'google-login-button',
              {
                  "onSuccess": this.onGoogleLoginSuccess,
                  "scope": "profile",
                  "theme": "dark"
              });
      }
  }
  
  onGoogleLoginSuccess(loggedInUser) {
      let idToken = loggedInUser.getAuthResponse().id_token;
  
      // here i can pass the idToken up to my server and validate it
  }
  </code></pre>
  
  <p>Now I have an idToken from google. The next step on the google pages found <a href="https://developers.google.com/identity/sign-in/web/backend-auth" rel="nofollow noreferrer">here</a> says that I need to validate the google accessToken, which I can do, but how do I exchange the accessToken that I have from google, and create local accessToken which can be used on my application?</p>