hendrikcech/tent-auth

bad statusCode: 422 if selfhosting

Opened this issue · 8 comments

If you selfhost a server and try auth.generateUrl() then you get just bad statusCode: 422 I assume it is because it is with the current tentd behind a BasicAuth. Tell me if you need a test server :)

Would be great if you could set me one up! I will look into it :)

Hm, I just tried it with my own test server hosted on Heroku, which also uses BasicAuth and I couldn't reproduce the error. A test entity on your server would definitely be helpful!

Or is it because I use a custom port?

No, that doesn't seem to be the reason, the request runs against http://tent.jeena.net:3005/apps
The error message is "Invalid Attributes" with a 422 statuscode.

Does the server log additional information? For example where the "semantic error" is?

Ok this is the error, it says that tentd tries to add the app without the name to the database and this casts the not-null-constraint.

ERROR -- : PG::Error: FEHLER:  NULL-Wert in Spalte »name« verletzt Not-Null-Constraint
DETAIL:  Fehlgeschlagene Zeile enthält (30, sbOjJccfcMvQfZd1i_NAPw, null, null, null, null, {}, {}, a:WsmNcHei3-KO-LF2ZIAjdg, aed276a6c192ecc099023a458e2a1a3c, hmac-sha-256, null, 2013-04-07 21:40:56.79159, 2013-04-07 21:40:56.791441, null, 1).: INSERT INTO "apps" ("updated_at", "public_id", "mac_key_id", "mac_key", "mac_algorithm", "user_id", "created_at") VALUES ('2013-04-07 21:40:56.791441+0200', 'sbOjJccfcMvQfZd1i_NAPw', 'a:WsmNcHei3-KO-LF2ZIAjdg', 'aed276a6c192ecc099023a458e2a1a3c', 'hmac-sha-256', 1, '2013-04-07 21:40:56.791590+0200') RETURNING*

As fas as I can see I am having this JSON which includes a name:

var app = {
    name: "example",
    url: "http://example.com",
    icon: "http://example.com/avatar.jpg",
    description: "A tent example.",
    redirect_uris: ["http://localhost:3000/auth/tent/callback"],
    scopes: {
        read_followers: "Collecting entities",
        read_followings: "Collecting entities",
        write_followings: "Ability to follow new entities",
        read_posts: "Collecting post data"
    }
}

Am I doing something wrong?

I will start working with a tent.is account for now but hopefully we can resolve this in the future.

No, you're doing everything right I guess, it should work.
I will look further into it, but I currently don't see the crucial difference between your server an tent.is. The custom port and the different protocol (http instead of https) probably aren't the deciding factor.
And the error message makes it even more cryptic :D