Skip to content Skip to sidebar Skip to footer

Google Oauth2 Get Token Javascript Post Request

I saw some questions and answers about this but couldn't understand what to do. I get this error: XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/token. No 'Access-

Solution 1:

Have you registered your app ?

Obtaining OAuth Keys :

  • Visit Google Cloud Console
  • Click CREATE PROJECT button
  • Enter Project Name, then click CREATE
  • Then select APIs & auth from the sidebar and click on Credentials tab

Note: Make sure you have turned on the APIs you need.

The important part is : Authorized Javascript origins: http://localhost:63342, you need to autorize your website domain to access the API.

The endpoint is bad use https://www.googleapis.com/oauth2/v3/tokenGoogle Doc:

$.ajax({
    url: "https://www.googleapis.com/oauth2/v3/token",
    data: {
        code :"",
        client_id : "",
        client_secret : "",
        redirect_uri : "",
        grant_type : "authorization_code"
    },
    method: "POST",
    success: function(e){console.log(e)}
});

Post a Comment for "Google Oauth2 Get Token Javascript Post Request"