-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
308d45a
commit b0fddc3
Showing
3 changed files
with
46 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import request from 'request' | ||
import querystring from 'querystring' | ||
import { config } from './oauth' | ||
|
||
/* Call into https://app.intercom.io/me and return user data */ | ||
export default function getUserData(token) { | ||
const postData = querystring.stringify({ | ||
client_id: config.clientId, | ||
client_secret: config.clientSecret, | ||
app_id: config.appId | ||
}) | ||
|
||
const requestOptions = { | ||
url: `${config.profilePath}?${postData}`, | ||
json: true, | ||
auth: { | ||
user: token.token.token, | ||
pass: '', | ||
}, | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
'Accept': 'application/json', | ||
} | ||
} | ||
|
||
return requestWrapper(requestOptions, token) | ||
} | ||
|
||
/* promisify request call */ | ||
function requestWrapper(requestOptions, token) { | ||
return new Promise((resolve, reject) => { | ||
request(requestOptions, (err, response, body) => { | ||
if (err) { | ||
return reject(err) | ||
} | ||
// return data | ||
return resolve({ | ||
token: token, | ||
data: body, | ||
}) | ||
}) | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.