A
A
Aleksey ladutska2019-09-08 22:53:20
OAuth
Aleksey ladutska, 2019-09-08 22:53:20

How to solve the problem with getting Google Access Token?

And am I making the request correctly? using axios in react

axios
      .post("https://www.googleapis.com/oauth2/v4/token", {
        grant_type: "authorization_code",
        code: CODE,
        client_id: CLIENT_ID,
        client_secret: CLIENT_SECRET,
        redirect_uri: URL_ADDRESS
      })
      .then(function(response) {
        console.log(response);
      })
      .catch(function(error) {
        console.log(error);
      });

xhr.js:166 POST https://www.googleapis.com/oauth2/v4/token 400
(anonymous) @ xhr.js:166
e.exports @ xhr.js:16
e.exports @ dispatchRequest.js:48
Promise.then (async)
c.request @ Axios.js:56
c.<computed> @ Axios.js:80
(anonymous) @ bind.js:11
a.handleSendEventsCalendar @ index.js:139
(anonymous) @ index.js:67
(anonymous) @ gapiScript.js:416
(anonymous) @ gapiScript.js:117
t @ gapiScript.js:415
F.S.<computed> @ gapiScript.js:427
F.f.<computed> @ gapiScript.js:434
(anonymous) @ cb=gapi.loaded_0:1
index.js:151 Error: Request failed with status code 400
    at e.exports (createError.js:17)
    at e.exports (settle.js:19)
    at XMLHttpRequest.f.onreadystatechange (xhr.js:60)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2019-09-09
@ladutia

So open the debugger and look at the server response, Google has a disgusting dock, but the responses of their services are usually adequate and make it easy to determine what the problem is.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question