Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5 from appsbynight/master

Add App Token (without tests)
  • Loading branch information...
commit 87a7f062057fbd3d8fc6e9ad9608f81fa81af250 2 parents 769f71c + 72ad176
@damienklinnert authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 lib/appdotnet.js
View
25 lib/appdotnet.js
@@ -76,6 +76,31 @@ AppDotNet.requestAccessToken = function (params, cb) {
};
/**
+ * Request an app access token with `params` and callback `cb(err, auth)`.
+ *
+ * @param {Object} params for the get parameters
+ * @param {Function} cb
+ */
+
+AppDotNet.requestAppToken = function (params, cb) {
+ var opts = {
+ uri: AppDotNet.authHost + '/oauth/access_token',
+ form: {
+ 'client_id': params.client_id,
+ 'client_secret': params.client_secret,
+ 'grant_type': 'client_credentials'
+ }
+ };
+ request.post(opts, function (err, resp, body) {
+ if (err) { return cb(err); }
+ var auth = JSON.parse(body);
+ if (auth.error) { return cb(auth.error); }
+
+ return cb(null, auth);
+ });
+};
+
+/**
* Retrieve the user with the given `id` and callback `cb(err, user)`.
*
* @param {String} id
Please sign in to comment.
Something went wrong with that request. Please try again.