Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

400 Bad Request - https://accounts.google.com/o/oauth2/token

Tags:

google-oauth

can anyone please tell me why this is bad request

var searchurl = "https://accounts.google.com/o/oauth2/token";

    $.ajax({
        dataType: "json",
        url:searchurl,
        context: {code:auth_code, client_id:'clientid', client_secret:'secret', redirect_uri:'http%3A%2F%2Flocalhost:8085%2FGmailIntegration%2FgetAuthResponse.jsp', grant_type:'authorization_code'},
        type:"POST",
        contentType:"application/x-www-form-urlencoded",
        success:function(data) {
            alert(data);
        },
        error: function(jqXHR, exception) {
            console.log(jqXHR);

        }
    });
like image 418
user3025605 Avatar asked Feb 17 '26 05:02

user3025605


1 Answers

I got this working.. i am sharing the code for those who are stuck with this:

$.ajax({
        dataType: "json",
        url:searchurl,
        data: {code:code, client_id:'clientid', client_secret:'secret', redirect_uri:'http://localhost:8085/GmailIntegration/getAuthResponse.jsp', grant_type:'authorization_code'},
        type:"POST",
        contentType:"application/x-www-form-urlencoded; charset=utf-8",
        crossDomain:true,
        cache : true, 
        success:function(data) {
            alert(data);
        },
        error: function(jqXHR, exception, errorstr) {
            console.log(jqXHR);
            alert(errorstr);
        }
    });

but now i have new issue. The url get 200 OK response but i am not getting response at all

enter image description here

like image 105
user3025605 Avatar answered Feb 19 '26 01:02

user3025605



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!