Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/doodle-node-cli / src / apis / doodle.js
Size: Mime:
const fetch = require('fetch-everywhere');
const { errorHandler, responseHandler } = require('./fetch');
const { DOODLE_ENVS, verboseLogging } = require('../constants');

/**
 * Set a password for a Keycloak user.
 *
 * @param {String} target - staging, devbox, etc
 * @param {String} accessToken - The users JWT token
 * @returns {Promise}
 */
const getUserInfo = (target, accessToken) => {
  const headers = {
    Authorization: `Bearer ${accessToken}`,
    'Content-Type': 'application/json',
  };

  const { monolithApiBase } = DOODLE_ENVS[target];
  const url = `${monolithApiBase}/v2.0/users/me`;

  if (verboseLogging) {
    console.log(`GET: ${url}`);
  }

  return fetch(url, { method: 'GET', headers })
    .then(responseHandler)
    .catch(errorHandler);
};

module.exports = {
  getUserInfo,
};