0
votes

Here is my code:

callGoogleAPi screen capture

Here is the response:

2020/09/14 12:19:51.425: INFO Results for adding ppsEmailAddress as recovery email: {data=[object Object], finalURL=https://www.googleapis.com/admin/directory/v1/users/[email protected], headers={Alt-Svc=h3-29=":443"; ma=2592000,h3-27=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43", Content-Length=357, Content-Type=application/json; charset=UTF-8, Date=Mon, 14 Sep 2020 19:19:51 GMT, Server=ESF, Vary=[Origin, X-Origin, Referer], X-Content-Type-Options=nosniff, X-Frame-Options=SAMEORIGIN, X-XSS-Protection=0}, initialURL=https://www.googleapis.com/admin/directory/v1/users/[email protected], statusCode=400.0, statusReason=Bad Request}

Full code: enter image description here

Trying to follow the Google API reference here, though something wrong with my syntax: https://developers.google.com/admin-sdk/directory/v1/reference/users#resource

1
Your code has an extra " - it reads ,""recoveryEmail:" when it should be ,"recoveryEmail:" - Is that the issue?iansedano
@iansedano That extra quote looks to be only in my StackOverflow post somehow. If you look at the screen capture you can see the exact code since it is a screen capture. The reason there was a typo only in StackOverflow is that platform I am required to use, I cannot copy and paste code to outside places. I know that may sound a bit crazy, but unfortunately that is a real limitation of this platform I am locked into.joshgoldeneagle
In your response, the finalURL endpoint has as its email "[email protected]@pps.net", is that it? I have checked the endpoint with your arguments (with a test account) and it works for me so it must be something to do with how the request is being constructed. Maybe you could share the code behind callGoogleAPI()? Or give more details about the platform you are using to make the request. You can also test your specific request using: developers.google.com/oauthplaygroundiansedano
@iansedano I will post the full code here as per your suggestion. I have updated the code so that the finalURL has a properly formatted email.joshgoldeneagle
There are many things missing in your question. You need to provide the code for callGoogleAPI or provide the details on complete http request sent to the server. From what I can see the google API expects a JSON. I don't see JSON in your request data. Probably the data should be "{receoveryEmail":+alternateEmail+"}"} instead of "receoveryEmail":+alternateEmail as passed by you.manishg

1 Answers

0
votes

I made a similar request using the Google OAuth Playground

This was the format of my request:

PATCH /admin/directory/v1/users/[email protected] HTTP/1.1
Host: www.googleapis.com
Content-length: 45
Content-type: application/json
Authorization: Bearer {REPLACE WITH ACCESS TOKEN}
{
recoveryEmail: "[email protected]"
}

Ensure that callGoogleAPI() makes a request in this format.

References: https://developers.google.com/admin-sdk/directory/v1/reference/users/patch