How to script google oauth2 to external website

Viewed 76

targetwebsite.com has a google login button that takes you to the website:

https://targetwebsite.com/login/google


As a response you get the location:

https://accounts.google.com/o/oauth2/auth?client_id=867328024096-e1p5hbmra2s0g2psgqhhl7ldafla8qr9.apps.googleusercontent.com&redirect_uri=https://targetwebsite.com/login/google&response_type=code&scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile&state=cH-mI0

Parts:

  1. https://accounts.google.com/o/oauth2/auth
  2. ?client_id=867328024096-e1p5hbmra2s0g2psgqhhl7ldafla8qr9.apps.googleusercontent.com
  3. &redirect_uri=https://targetwebsite.com/login/google
  4. &response_type=code
  5. &scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
  6. &state=cH-mI0

If you log in there with google you come back to link

https://targetwebsite.com/login/google?state=cH-mI0&code=4/0AX4XfWjOprw2J7PfNFkaOCWLEAAiGDkm7UJQPmnzLRwnfp4IhhHf37XoyNsvr3DCGzmRcA&scope=email%20profile%20https://www.googleapis.com/auth/userinfo.profile%20openid%20https://www.googleapis.com/auth/userinfo.email&authuser=1&prompt=none

The part "code=4/0AX4X..." is different for each login.


How would it be possible to automate this process? (in Powershell)

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.

0 Answers
Related