Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A798010A41 for ; Tue, 1 Oct 2013 23:14:24 +0000 (UTC) Received: (qmail 49000 invoked by uid 500); 1 Oct 2013 23:14:23 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 48962 invoked by uid 500); 1 Oct 2013 23:14:23 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 48954 invoked by uid 99); 1 Oct 2013 23:14:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Oct 2013 23:14:23 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of kxepal@gmail.com designates 74.125.82.182 as permitted sender) Received: from [74.125.82.182] (HELO mail-we0-f182.google.com) (74.125.82.182) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Oct 2013 23:14:19 +0000 Received: by mail-we0-f182.google.com with SMTP id t61so32621wes.27 for ; Tue, 01 Oct 2013 16:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=52Vnu5tORDENOVpftsozb9tAUjh/zg7QjFZfarqUltI=; b=SVtfjEi3Om5Qff0VuA8bj+WJnuKerZf0o3I4EkdRUVf0pxXc28jGOe1j9dQ17wc7Ud IGuISh/+fXBmGgdqRiXYbmBCZsVZ+OSkIHReRkXpqp6ZPKoblaeaM2mi25uoSc2/l8fG XJnyHarI1jMiHG9wLlU55swwzx7jOVgodZ8+biOya1ts65/B4tOwULpyJdA9YgRrR4U2 waUN6Y6yBaHmeLxTW6Ui2mhRDE1B8mjPnj0Q7gE0z5EGVWio6ByEiQ0g9z2WhSZ4TlJU RMY+EZKt7X1y0XOiMHVUDGyWXnNlGhvf2DGHmnTRLVOV7ggwcb76n3Uk9mal9NX4FpuH 652w== MIME-Version: 1.0 X-Received: by 10.194.110.138 with SMTP id ia10mr25391816wjb.3.1380669238376; Tue, 01 Oct 2013 16:13:58 -0700 (PDT) Received: by 10.180.79.35 with HTTP; Tue, 1 Oct 2013 16:13:58 -0700 (PDT) In-Reply-To: References: Date: Wed, 2 Oct 2013 03:13:58 +0400 Message-ID: Subject: Re: _session authentication to CouchDB from AngularJS From: Alexander Shorin To: "user@couchdb.apache.org" Content-Type: text/plain; charset=UTF-8 X-Virus-Checked: Checked by ClamAV on apache.org Hi Mark, To use Cookie auth you need to make two actions: 1. POST /_session with user's credentials and get the AuthSession cookie http://docs.couchdb.org/en/latest/api/server/authn.html#post--_session 2. Make any other request with the received cookie. Example: http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session For AngularjS side you need to access $cookies object to get/set the cookie and $cookiesStore to keep it for a long time within your app http://docs.angularjs.org/api/ngCookies Also take a look on this blog post: https://www.twilio.com/blog/2013/08/votr-part-4-angularjs-and-authentication-with-couchdb.html They uses similar idea, but with their own methods as I see in the code examples. Hope this helps. -- ,,,^..^,,, On Wed, Oct 2, 2013 at 2:57 AM, Mark Deibert wrote: > I've been searching and reading articles for a full 2 weeks of evenings > after work. No matter what I'm finding/trying, I cannot get CouchDB > _session/cookie authentication to work. I can get the first part to work, I > can setup and send the initial POST to _session with a valid user/pass and > I get a positive response from Couch. In Chrome console I see the > AuthSession cookie comes back in the response. But sadly, from here, I get > 401 "not authorized" on all subsequent GET, PUT, whatever. > > I think on the entire surface of the earth there is only me and maybe 4 or > 5 other guys that are trying to use CouchDB with AngularJS because I can't > get this resolved no matter where I post. > > Is anyone in this group using AngluarJS with CouchDB? If yes, are you using > AuthSession cookie authentication? If yes, pleeeeeeeeeeeeeeese help! :-/ > I've gotten almost no where for 2 weeks now. > > Thank, thank you, thank you, thank you for any advice you can provide.