Skip to content

Commit

Permalink
Merge pull request #34 from maximchouinard/master
Browse files Browse the repository at this point in the history
support for personal access token
  • Loading branch information
dburles committed Oct 13, 2016
2 parents cba8185 + 19cbea5 commit 6a3b058
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $ meteor add verso:intercom

## API

Ensure you have `Meteor.settings.intercom.secret` and `Meteor.settings.public.intercom.id` defined to the values provided to you by Intercom. Also define `Meteor.settings.intercom.apikey` if you intend to use Intercom on the server side.
Ensure you have `Meteor.settings.intercom.secret` and `Meteor.settings.public.intercom.id` defined to the values provided to you by Intercom. *API Keys are being deprecated*. You can define the `Meteor.settings.intercom.personalAccessToken` if you intend to use Intercom on the server side, otherwise you can still define `Meteor.settings.intercom.apikey`.

Some Intercom subscription packages allow for anonymous users. To enable the use of anonymous users, set `Meteor.settings.public.intercom.allowAnonymous` to `true`.

Expand Down
14 changes: 12 additions & 2 deletions intercom_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ var crypto = Npm.require('crypto');
var Intercom = Npm.require('intercom-client');

IntercomClient = function IntercomClient() {
//support for Personal Access token:
const pat = Meteor._get(Meteor, 'settings', 'intercom', 'personalAccessToken');

//api
const id = Meteor._get(Meteor, 'settings', 'public', 'intercom', 'id');
const apikey = Meteor._get(Meteor, 'settings', 'intercom', 'apikey');

//priority
if (pat) {
return new Intercom.Client({ token: pat });
}

if (id && apikey) {
return new Intercom.Client(id, apikey);
}

return console.warn(`
You must set Meteor.settings.public.intercom.id
and Meteor.settings.intercom.apikey to use IntercomClient
You must set Meteor.settings.intercom.personalAccessToken
or add Meteor.settings.public.intercom.id
and Meteor.settings.intercom.apikey to use IntercomClient
`);
};

Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Package.describe({
git: 'https://github.com/versolearning/meteor-intercom.git'
});

Npm.depends({ 'intercom-client': '2.8.1' });
Npm.depends({ 'intercom-client': '2.8.3' });

Package.onUse(function(api) {
if (api.versionsFrom)
Expand Down

0 comments on commit 6a3b058

Please sign in to comment.