0
The thing is, I’m using the google api to build an app. However, I got to this part below and I can’t do it at all. How do I do this POST q it asks me? I already have all the parameter data.
Below the google help snippet:
Supondo que o usuário tenha acesso a seu aplicativo, troque o código de autorização recebido na etapa 3 por um toque de atualização e um token de acesso. Envie uma solicitação POST para https://accounts.google.com/o/oauth2/token
Veja um exemplo de solicitação abaixo:
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=4/ux5gNj-_mIu4DOD_gNZdjX9EtOFf&
client_id=1084945748469-eg34imk572gdhu83gj5p0an9fut6urp5.apps.googleusercontent.com&
client_secret=hDBmMRhz7eJRsM9Z2q1oFBSe&
redirect_uri=http://localhost/oauth2callback&
grant_type=authorization_code
And this post was to return me the following:
{
"access_token" : "ya29.AHES6ZTtm7SuokEB-RGtbBty9IIlNiP9-eNMMQKtXdMP3sfjL1Fc",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "1/HKSmLFXzqP0leUihZp2xUt3-5wkU7Gmu2Os_eBnzw74"
}
Blz, I’m going to do a test. How do I save the parameters in the date variable? Can I do date = 'parameters?'
– Thiago
I will edit the answer with these instructions.
– lfarroco
See, man, you did. However, he gave this error: Xmlhttprequest cannot load https://accounts.google.com/o/oauth2/token. No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://localhost' is therefore not allowed access. The Response had HTTP status code 400. q may be?
– Thiago
This error means that the server that is receiving your post is not configured to receive requests from the localhost address. In this case the solution varies according to the API or service you want to send.
– lfarroco