Reputation: 83
Hi I am trying to parser the json response of the url but i am not able to do it.
$(document).ready(function() {
$.getJSON('https://www.googleapis.com/oauth2/v1/userinfo?&access_token=xxxxxxxxxxxxx&token_type=Bearer&expires_in=3600', function(data) {
alert (c.email);
});
});
In this page there is my code http://pastie.org/3379735
I hope you can help me.
Upvotes: 0
Views: 306
Reputation: 3532
What is c.email, think you want data.email
$(document).ready(function() {
$.getJSON('https://www.googleapis.com/oauth2/v1/userinfo?&access_token=xxxxxxxxxxxxx&token_type=Bearer&expires_in=3600&callback=?', function(data) {
alert (data.email);
});
});
Update
as the OP has now stated after reading the documentation you need to provied the callback for jsonp as part of the path, not the params in the form of
https://oauth2-login-demo.appspot.com/oauthcallback?code={authorizationCode}
docs can be found here
Upvotes: 2
Reputation: 1038780
Due to the same origin policy restriction you cannot send cross domain AJAX requests. There's no JSONP support for this so you cannot directly access his url from your code.
You may take a look at the following demo based on the gwt-oauth2.js script which uses this code to authenticate with Google.
Upvotes: 0