Skip to content

401 Unauthorized after successful login #268

@rehovicova

Description

@rehovicova

Expected Behavior

I expect I can query the database after login without getting 401

Current Behavior

I am getting 401 after successful login

Code

let PouchDB = require('pouchdb')
PouchDB.plugin(require('pouchdb-authentication'))

let localDb = PouchDB(dbConfig.dbName);
let remoteDb = PouchDB(`http://${dbConfig.host}:5984/${dbConfig.dbName}`, { skip_setup: true })
remoteDb.login(dbConfig.username, dbConfig.password).then( result => {
    console.log(result) // <--- { ok: true, name: 'admin', roles: [ '_admin' ] }

    remoteDb.get(id).then( r => console.log(r)).catch( e => console.log(e));
    // Prints
    //  {
    //    error: 'unauthorized',
    //    reason: 'You are not authorized to access this db.',
    //     status: 401,
    //    name: 'unauthorized',
    //    message: 'You are not authorized to access this db.',
    //    docId: 'some_id'
    //  }

}).catch( e => logger.error(`${TAG}: ${e}`))

Your Environment

  • Version of PouchDB Authentication: 1.1.3
  • Version of PouchDB: 7.2.1
  • Platform name and version: Node.js 12.16.3

PS: I am connecting to the same database from a different project using JavaScript and PouchDB 7.2.1 and auth 1.1.3 (so exactly the same) and it works jut fine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions