With the clientId and clientSecret, is there a way to use JavaScript to get the accessToken through ajax?


If you are using node.js, you can do so by using the Node.js client for ExactTarget's Fuel REST APIs.

var fuel = require('fuel').configure({
    authUrl: 'https://auth.exacttargetapis.com/v1/requestToken',
    clientId: 'xxxxxxxxxxxxxxxxxxxxxxxx',
    clientSecret: 'yyyyyyyyyyyyyyyyyyyyyyyy'
  • 2
    Can I just have it as pure client side without relying on server (in this case, nodejs)? – Roger Ng Sep 9 '14 at 6:47

Yes. Use a jquery.post to https://auth.exacttargetapis.com/v1/requestToken with your clientId and clientSecret in the payload. The result will contain your oauth token.

  • 1
    Hi Timothy, thanks for your answer but I tried that using jquery ajax, what I get in return is cross origin error but the network transaction is 200 OK, do you have any code sample that I can look at? – Roger Ng Sep 9 '14 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.