Reputation: 590
I'm trying to make a POST request using JQuery and the API that I'm reading about says this:
On your server, you can now make the following request to obtain an access token:
POST https://api.twitch.tv/kraken/oauth2/token
POST Body (URL-encoded)
client_id=[your client ID] &client_secret=[your client secret] &grant_type=authorization_code &redirect_uri=[your registered redirect URI] &code=[code received from redirect URI]
How would this POST request look in javascript? I'm pretty new to JS/Jquery in general so I don't know much about RESTful calls.
This is what I tried:
$.post( "https://api.twitch.tv/kraken/oauth2/token?client_id=" + clientID
+ "&client_secret=" + clientSecret
+ "&grant_type=authorization_code&redirect_uri="+ redirectURI
+ "&code=" + code,
function( data ) {
grabUserAccessTok(data );
});
Upvotes: 0
Views: 267
Reputation: 2204
Try this out :
$.post("https://api.twitch.tv/kraken/oauth2/token", {
client_id: clientID,
client_secret: clientSecret,
grant_type : authorization_code,
redirect_uri: redirectURI,
code: code
},
function(data) {
grabUserAccessTok(data);
});
Upvotes: 0