title: How to script google oauth2 to external website
body: <p>targetwebsite.com has a google login button that takes you to the website:</p>
  <blockquote>
  <p><a href="https://targetwebsite.com/login/google" rel="nofollow noreferrer">https://targetwebsite.com/login/google</a></p>
  </blockquote>
  <hr />
  <p>As a response you get the location:</p>
  <blockquote>
  <p><a href="https://accounts.google.com/o/oauth2/auth?client_id=867328024096-e1p5hbmra2s0g2psgqhhl7ldafla8qr9.apps.googleusercontent.com&amp;redirect_uri=https://targetwebsite.com/login/google&amp;response_type=code&amp;scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile&amp;state=cH-mI0" rel="nofollow noreferrer">https://accounts.google.com/o/oauth2/auth?client_id=867328024096-e1p5hbmra2s0g2psgqhhl7ldafla8qr9.apps.googleusercontent.com&amp;redirect_uri=https://targetwebsite.com/login/google&amp;response_type=code&amp;scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile&amp;state=cH-mI0</a></p>
  </blockquote>
  <p>Parts:</p>
  <ol>
  <li><a href="https://accounts.google.com/o/oauth2/auth" rel="nofollow noreferrer">https://accounts.google.com/o/oauth2/auth</a></li>
  <li>?client_id=867328024096-e1p5hbmra2s0g2psgqhhl7ldafla8qr9.apps.googleusercontent.com</li>
  <li>&amp;redirect_uri=https://targetwebsite.com/login/google</li>
  <li>&amp;response_type=code</li>
  <li>&amp;scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile</li>
  <li>&amp;state=cH-mI0</li>
  </ol>
  <hr />
  <p>If you log in there with google you come back to link</p>
  <blockquote>
  <p><a href="https://targetwebsite.com/login/google?state=cH-mI0&amp;code=4/0AX4XfWjOprw2J7PfNFkaOCWLEAAiGDkm7UJQPmnzLRwnfp4IhhHf37XoyNsvr3DCGzmRcA&amp;scope=email%20profile%20https://www.googleapis.com/auth/userinfo.profile%20openid%20https://www.googleapis.com/auth/userinfo.email&amp;authuser=1&amp;prompt=none" rel="nofollow noreferrer">https://targetwebsite.com/login/google?state=cH-mI0&amp;code=4/0AX4XfWjOprw2J7PfNFkaOCWLEAAiGDkm7UJQPmnzLRwnfp4IhhHf37XoyNsvr3DCGzmRcA&amp;scope=email%20profile%20https://www.googleapis.com/auth/userinfo.profile%20openid%20https://www.googleapis.com/auth/userinfo.email&amp;authuser=1&amp;prompt=none</a></p>
  </blockquote>
  <p>The part &quot;code=4/0AX4X...&quot; is different for each login.</p>
  <hr />
  <p><strong>How would it be possible to automate this process?</strong> (in Powershell)</p>
  <p><strong>As far as I understand, Google only allows you to create permanent login tokens for your own projects, not for others as in this case.</strong></p>