I'm attempting to using AngularJS to access the API using JSONP (eg ?callback=JSON_CALLBACK, via this ST question) and I'm getting a 404 when hitting the /oauth/token endpoint.
Is JSONP enabled? If so, what might I be doing wrong here?
Relevant code below:
$http.jsonp('https://my_nation.nationbuilder.com/oauth/token?callback=JSON_CALLBACK', {
method: 'POST',
data: {
client_id: 'CLIENT_ID',
redirect_uri: 'http://localhost:9000',
grant_type: 'authorization_code',
client_secret: 'SECRET',
code: 'CODE',
}
})
Share this post
Showing 3 reactions
Sign in with
Trying this with the people endpoint did work bringing back data, but it does not seem to have sent it back within a callback, just the pure JSON (eg "Uncaught SyntaxError: Unexpected token : " error, http://stackoverflow.com/questions/7936610/json-uncaught-syntaxerror-unexpected-token).
Here is the smallest test case in Angular I could come up with:
function PersonCtrl ($scope, $http, $log) {
$http.jsonp(‘https://chimera.nationbuilder.com/api/v1/people?callback=JSON_CALLBACK’, {
method: ‘GET’,
params: {
access_token: ‘ACCESS_TOKEN_HERE’
}
})
.success(function (data, status, headers, config) {
$log.log(data, status, config);
})
.error(function (data, status, headers, config) {
$log.log(data, status, config);
});
}