Saturday, June 2, 2012

[YouTube-API] OAuth2.0 Error : 405 method not allowed ?

Hi All,
 
        I am facing one problem to get the access token for youtube API using oAuth2.0.  I got the the "code" parameter.

        But when I tried to exchange the "code" parameter for access token  it's throwing an error 405, Method not allowed.  

        Even the simple http request for access token without any parameters "https://accounts.google.com/o/oauth2" throwing the same error. 

       here is my sample code:
       
$.ajax({
url:'https://accounts.google.com/o/oauth2/token',
method: 'POST',
host: 'accounts.google.com',
                contentType: 'application/x-www-form-urlencoded',
data : {
code : '4/MPH9vS5QCvJs9PB_b_tw5n3Avpvs.0vEfS-A70z4TgrKXntQAax0EzVBNbwI',
client_id : '6656895612.apps.googleusercontent.com',
client_secret : 'kiuSP80klPiYCB-xN8vYPi0R',
redirect_uri : 'http://localhost:8080/user/admin/my-space',
grant_type : 'authorization_code'
},
success :function(data){
var jsonObj = jQuery.parseJSON(data); 
alert(jsonObj);
}
});

      In my above code, I am getting jsonObj as null
     
      I have gone through the forum, and read all the posts related to this error but I did not get any solution over there. Even I am sending the HTTP Post method instead of    Get method but still I get the same error.

      Please let me know If there is anything wrong with the above code. Any help would be appreciated.

     Thanks in advance.

     Regards,
      Gauri

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/WyYF_17oqvoJ.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment