web2py and jwt

295 views
Skip to first unread message

Abdu Adil

unread,
Jul 27, 2016, 2:56:32 AM7/27/16
to web2py-users
(I used this link to add jwt())

I want to use restful API with JWT, so I did this

auth = Auth(db, host_names=myconf.get('host.names'), jwt = {'secret_key':'secret'})

Then in defaults controller I have this

def user():
    return dict(form=auth())

In my api controller i have

@request.restful()
@auth.allows_jwt()
@auth.requires_login()
def role():
        response.view = 'generic.json'
        def GET(id):
            return dict(roles = db().select(db.role.ALL))

        def POST(tablename, **fields):
            return db.roles.validate_and_insert(**fields)

        return locals()

When I try to log in first with POST request on this path


Not Authorized - need to be logged in, to pass a token for refresh or username and password for login

What do I need to fix here ?

Niphlod

unread,
Jul 28, 2016, 10:13:12 AM7/28/16
to web2py-users
ahem. a GET instead of a POST.
Reply all
Reply to author
Forward
0 new messages