- Purpose : Get google oauth2 token by command line
- Open browser to authenticate
- Get
Sub
andId token
- Google Oauth2 DOC : https://developers.google.com/google-ads/api/docs/concepts/curl-example
- https://developers.google.com/identity/protocols/oauth2
- Follow google doc to get
client_id
,client_secret
,redirect_uri
- Make sure the reditect_uri have localhost setting,
http://localhost:8080/.....
- Make sure the reditect_uri have localhost setting,
id="......." &&\
secret="......." &&\
uri="http://localhost:8080/....." &&\
go run main.go -id=$id -secret=$secret -redirectUri=$uri
pm.sendRequest('http://localhost:8080/postman', (error, response) => {
if (error) {
console.log(error);
} else {
console.log(response.json().sub);
console.log(response.json().id_token);
//
pm.environment.set("google_oauth_sub", response.json().sub);
pm.environment.set("google_oauth_id_token", response.json().id_token);
}
});
- {{google_oauth_sub}}
- {{google_oauth_id_token}}