question

ryandj avatar image
ryandj asked

Google api oauth

Im trying to use google api and oauth form cloud script. I have tried everything an I'm stuck with error after error.

tried this no joy

//Cloud Script

var url = "https://accounts.google.com/o/oauth2/v2/auth?";

var method = "post";

var contentBody = "grant_type=client_credentials";

var contentType = "application/x-www-form-urlencoded";

var Headers = {};

Headers["prompt"] = "consent";

Headers["response_type"] = "code";

Headers["client_id"] = "my id";

Headers["scope"] = "https://Fwww.googleapis.com/auth/adsense";

Headers["access_type"] = "offline"; Headers["approval_prompt"] = "force";

var tokenResponse = http.request(url,method,contentBody,contentType,Headers);

get this error missing response type

so I tried using this method

//Cloud Script

var url = "https://accounts.google.com/o/oauth2/v2/auth?";

var method = "post";

var contentBody = "redirect_uri=https%3A%2F%2Fa2f6.playfabapi.com%2F&prompt=consent&response_type=code&client_id=myid&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadsense&access_type=offline";

var contentType = "application/x-www-form-urlencoded";

var headers = {};

var tokenResponse = http.request(url,method,contentBody,contentType,headers);

log.debug(tokenResponse);

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

May I ask what is the scenario that you need to implement google authentication on Cloud script? In addition, is there any detailed error message reported?

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.