librelist archives

« back to archive

How to setup authentication with Flask plugin "Authomatic" ?

How to setup authentication with Flask plugin "Authomatic" ?

From:
Julien Meyer
Date:
2013-12-11 @ 18:12
Hi guys,

I'm trying to use the extra FlaskAuthomatic from Authomatic plugin

http://peterhudec.github.io/authomatic/_modules/authomatic/extras/flask.html#FlaskAuthomatic

I'm fairly new to Python can't figure out how to use it.

Here is what I came with so far :

-----------
from config import CONFIG
from authomatic.extras.flask import FlaskAuthomatic

FA = FlaskAuthomatic(CONFIG, 'thisIsMySecretString', 600, True)
result = FA.login()
print (result.user)
-----------

Which returns :
AttributeError: 'function' object has no attribute 'user'

I tried the basic example from Authomatic which works fine, but I dont
understand how to use this decorator.

Thanks for your help

- Julien

Re: [flask] How to setup authentication with Flask plugin "Authomatic" ?

From:
Laszlo Papp
Date:
2013-12-11 @ 18:19
Have you checked this example?

http://peterhudec.github.io/authomatic/examples/flask-simple.html

On Wed, Dec 11, 2013 at 6:12 PM, Julien Meyer <jmeyer@itpros.fr> wrote:
> Hi guys,
>
> I'm trying to use the extra FlaskAuthomatic from Authomatic plugin
> 
http://peterhudec.github.io/authomatic/_modules/authomatic/extras/flask.html#FlaskAuthomatic
>
> I'm fairly new to Python can't figure out how to use it.
>
> Here is what I came with so far :
>
> -----------
> from config import CONFIG
> from authomatic.extras.flask import FlaskAuthomatic
>
> FA = FlaskAuthomatic(CONFIG, 'thisIsMySecretString', 600, True)
> result = FA.login()
> print (result.user)
> -----------
>
> Which returns :
> AttributeError: 'function' object has no attribute 'user'
>
> I tried the basic example from Authomatic which works fine, but I dont
> understand how to use this decorator.
>
> Thanks for your help
>
> - Julien

Re: [flask] How to setup authentication with Flask plugin "Authomatic" ?

From:
Julien Meyer
Date:
2013-12-11 @ 18:26
Yes, this one works fine though the session is killed immediately after the
login process.

The FlaskAuthomatic "extra" seems to get this done with a timestamp
specified in the function params, this is why I'm trying to get it works.

Thing is, I think I don't get the real advantage of this decorator : what
are the true benefits of it ?

Otherwise I guess I have to find a way to keep the session alive after a
successfull login, using only Flask sessions.


On Wed, Dec 11, 2013 at 7:19 PM, Laszlo Papp <lpapp@kde.org> wrote:

> Have you checked this example?
>
> http://peterhudec.github.io/authomatic/examples/flask-simple.html
>
> On Wed, Dec 11, 2013 at 6:12 PM, Julien Meyer <jmeyer@itpros.fr> wrote:
> > Hi guys,
> >
> > I'm trying to use the extra FlaskAuthomatic from Authomatic plugin
> >
> 
http://peterhudec.github.io/authomatic/_modules/authomatic/extras/flask.html#FlaskAuthomatic
> >
> > I'm fairly new to Python can't figure out how to use it.
> >
> > Here is what I came with so far :
> >
> > -----------
> > from config import CONFIG
> > from authomatic.extras.flask import FlaskAuthomatic
> >
> > FA = FlaskAuthomatic(CONFIG, 'thisIsMySecretString', 600, True)
> > result = FA.login()
> > print (result.user)
> > -----------
> >
> > Which returns :
> > AttributeError: 'function' object has no attribute 'user'
> >
> > I tried the basic example from Authomatic which works fine, but I dont
> > understand how to use this decorator.
> >
> > Thanks for your help
> >
> > - Julien
>

Re: [flask] How to setup authentication with Flask plugin "Authomatic" ?

From:
Julien Meyer
Date:
2013-12-13 @ 06:32
Just to close this thread:

Since I can't figure out how to use this decorator function, I now use the
default Flask example from Authomatic + Flask default session (
http://flask.pocoo.org/docs/quickstart/#sessions) to store the user's infos
after a successfull login.

- JM


On Wed, Dec 11, 2013 at 7:26 PM, Julien Meyer <jmeyer@itpros.fr> wrote:

> Yes, this one works fine though the session is killed immediately after
> the login process.
>
> The FlaskAuthomatic "extra" seems to get this done with a timestamp
> specified in the function params, this is why I'm trying to get it works.
>
> Thing is, I think I don't get the real advantage of this decorator : what
> are the true benefits of it ?
>
> Otherwise I guess I have to find a way to keep the session alive after a
> successfull login, using only Flask sessions.
>
>
> On Wed, Dec 11, 2013 at 7:19 PM, Laszlo Papp <lpapp@kde.org> wrote:
>
>> Have you checked this example?
>>
>> http://peterhudec.github.io/authomatic/examples/flask-simple.html
>>
>> On Wed, Dec 11, 2013 at 6:12 PM, Julien Meyer <jmeyer@itpros.fr> wrote:
>> > Hi guys,
>> >
>> > I'm trying to use the extra FlaskAuthomatic from Authomatic plugin
>> >
>> 
http://peterhudec.github.io/authomatic/_modules/authomatic/extras/flask.html#FlaskAuthomatic
>> >
>> > I'm fairly new to Python can't figure out how to use it.
>> >
>> > Here is what I came with so far :
>> >
>> > -----------
>> > from config import CONFIG
>> > from authomatic.extras.flask import FlaskAuthomatic
>> >
>> > FA = FlaskAuthomatic(CONFIG, 'thisIsMySecretString', 600, True)
>> > result = FA.login()
>> > print (result.user)
>> > -----------
>> >
>> > Which returns :
>> > AttributeError: 'function' object has no attribute 'user'
>> >
>> > I tried the basic example from Authomatic which works fine, but I dont
>> > understand how to use this decorator.
>> >
>> > Thanks for your help
>> >
>> > - Julien
>>
>
>

Re: [flask] How to setup authentication with Flask plugin "Authomatic" ?

From:
Laszlo Papp
Date:
2013-12-11 @ 18:23
On Wed, Dec 11, 2013 at 6:12 PM, Julien Meyer <jmeyer@itpros.fr> wrote:
> Which returns :
> AttributeError: 'function' object has no attribute 'user'

You did not check against zero for the result, nor for the result.user
as in the example.

> I tried the basic example from Authomatic which works fine, but I dont
> understand how to use this decorator.

You mean the one I provided? Well, you could also show your config.
Also, modify step-by-step. Do not modify the CONFIG _and_ the FA call
in the same step. Try to localize the issue.

Cheers, L.