Created
February 13, 2014 22:39
-
-
Save heridev/8985406 to your computer and use it in GitHub Desktop.
Probar funcionalidad de api en rails con ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Para generar un nuevo token desde la api usamos lo siguiente: | |
var server = 'http://localhost:3000'; | |
var userAuthUrl = server + '/api/sessions/create?access_token='; | |
$.ajax({ | |
url: userAuthUrl + access_token, | |
success: function(resp) { | |
console.log(resp); | |
} | |
}); | |
Para poder validar nuestro token desde la api de google tenemos el siguiente codigo de ejemplo: | |
var google_url = 'https://www.googleapis.com/oauth2/v1/userinfo?access_token='; | |
var token = '' | |
$.ajax({ | |
url: google_url + token, | |
data: null, | |
success: function(resp) { | |
user = resp; | |
console.log(user); | |
}, | |
dataType: "jsonp" | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment