How to use the cozy-client-js.MemoryStorage function in cozy-client-js

To help you get started, we’ve selected a few cozy-client-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cozy / cozy.github.io / en / ach / libs / getClient.js View on Github external
exported.getClientWithoutToken = tokenPath => (url, docTypes = []) => {
  let permissions = docTypes.map(docType => docType.toString() + ':ALL')

  // Needed for ACH revocation after execution
  permissions.push('io.cozy.oauth.clients:ALL')

  let cozyClient = new cozy.Client({
    cozyURL: url,
    oauth: {
      storage: new cozy.MemoryStorage(),
      clientParams: {
        redirectURI: 'http://localhost:3333/do_access',
        softwareID: SOFTWARE_ID,
        clientName: CLIENT_NAME,
        scopes: permissions
      },
      onRegistered: onRegistered
    }
  })

  return cozyClient.authorize().then(creds => {
    let token = creds.token.accessToken
    cozyClient._token = new AppToken({ token })

    log.debug('Writing token file to ' + tokenPath)
    fs.writeFileSync(tokenPath, JSON.stringify({ token: token }), 'utf8')

cozy-client-js

Javascript library to interact with a cozy

MIT
Latest version published 1 year ago

Package Health Score

46 / 100
Full package analysis