-
Notifications
You must be signed in to change notification settings - Fork 118
Despite response.ok being true I afterwards get an unauthorized error #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am getting the same thing. |
Could it have to do with encoding?
try:
window.btoa(unescape(encodeURIComponent(user.name + ":" + user.password)))
…On Thu, 14 Nov 2019 at 12:41, Christian Kleineidam ***@***.***> wrote:
Expected Behavior
If response.ok from pouchdb.logIn is true, calling pouchdb.info()
shouldn't throw an error
Current Behavior
After I get response.ok from pouchdb.logIn is true, I get an
"error:unauthorized" for calling pouchdb.info().
I use the following code to unsuccessfully login:
export function logIntoCouch(user: Credentials, pouch_db_name:string): Promise<PouchDB.Database<{}>> {
const pouchOpts = {
skip_setup: true
}
let pouchdb = new PouchDB(pouch_db_name, pouchOpts)
const authOptions: AuthOptions = {
ajax: {
headers: {
Authorization: "Basic " + window.btoa(user.name + ":" + user.password)
}
}
}
return new Promise<PouchDB.Database>(
async (
resolve: (value?: PromiseLike<PouchDB.Database> | PouchDB.Database) => void,
reject: (reason?: any) => void
) => {
await pouchdb
.logIn(user.name, user.password, authOptions)
.then(async (response: PouchDB.Authentication.LoginResponse) => {
if (response.ok) {
await pouchdb.info()
.then(resp=>{
console.log(resp)}
)
resolve(pouchdb)
} else reject(response)
})
.catch((error: any) => {
reject(error)
})
}
)
}
Context
I want to login into a remote CouchDB (currently on localhost) with
PouchDB that uses username/password authentification.
Your Environment
- Version of PouchDB Authentication: "^1.1.3"
- Version of PouchDB: "^7.1.1"
- Platform name and version: Intellij, Jest Unittest -->
- Operating System and version: Windows10, -->
- Server: Apache CouchDB v. 2.3.1
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#258?email_source=notifications&email_token=ABKTZUWVSEQOG6P327ECPDDQTU2M5A5CNFSM4JNKFWJ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HZJLMIQ>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKTZUX6YCJEDC5BLTFQJF3QTU2M5ANCNFSM4JNKFWJQ>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior
If response.ok from pouchdb.logIn is true, calling pouchdb.info() shouldn't throw an error
Current Behavior
After I get response.ok from pouchdb.logIn is true, I get an "error:unauthorized" for calling pouchdb.info().
I use the following code to unsuccessfully login:
Context
I want to login into a remote CouchDB (currently on localhost) with PouchDB that uses username/password authentification.
Your Environment
The text was updated successfully, but these errors were encountered: