couchdb sessions
Created by: squirrelpiles
Hello,
It seems like I can authenticate and create a session in couchdb, but subsequent calls to methods do not use the session. In the example below, I authenticate (do I?) and then attempt to get a list of changes. The user account I use is an admin.
Any help would be appreciated.
here is test code I am using: local spore = require 'Spore' spore.debug = io.stdout arg.spore_base = "file:/home/dave/creeksidedepot/ferret/src/lua/"
local base = arg.spore_base local couchdb = spore.new_from_spec( base .. "server.json", base .. "database.json", base .. "document.json", base .. "design.json", --{ base_url = "http://localhost:5984"} { base_url = "https://app.myserver.com/"}
) couchdb:enable_if(function (req) return req.env.spore.caller ~= 'get_attachment' end, 'Format.JSON')
payload = { name = "xxxx", password = "xxxxx" }
print("1 ------------------------------------") local r = couchdb:new_session{ payload = payload }; print(r.body.ok)
print("2 ------------------------------------") local r = couchdb:get_session() print(r.body.ok)
print("3 ------------------------------------") -- this fails with a 401 error. local r = couchdb:get_changes{ db = "_users", } print(r.body.ok)
output from above code (with proper name and password): 1 ------------------------------------ POST https://app.datawhere.com/_session user-agent: lua-Spore v0.3.0 content-type: application/json content-length: 37 accept: application/json HTTP/1.1 200 OK true 2 ------------------------------------ GET https://app.datawhere.com/_session user-agent: lua-Spore v0.3.0 accept: application/json HTTP/1.1 200 OK true 3 ------------------------------------ GET https://app.datawhere.com/_users/_changes user-agent: lua-Spore v0.3.0 accept: application/json HTTP/1.1 401 Unauthorized GET https://app.datawhere.com:443/_users/_changes 401 lua: (error object is not a string)