Ask Your Question

How can I add an oauth2 custom login provider to askbot ?

asked 2013-01-17 18:17:43 -0500

Fabien Meghazi gravatar image

How can I add an oauth2 custom login provider to askbot ?

I grepped askbot code and it seems that it supports oauth2, right ?

askbot/deps/django_authopenid/ oauth2 as oauth
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-01-18 14:50:44 -0500

Evgeny gravatar image

updated 2014-11-16 11:54:53 -0500

It is possible by implementing a special module and adding python path to that module in the file:

ASKBOT_CUSTOM_AUTH_MODULE = 'myapp.my_login_method' #the app must be on the python path

Only one custom method is supported at the moment per site.

The module can have the following variables:

BIG_BUTTON - optional, boolean, True|False, default=True, if true, button will be big
ORDER_NUMBER - optional, integer, default=1, position in the row of buttons
ICON_MEDIA_PATH - required, string, url to the image of the login button
TOOLTIP_TEXT - required, string, tooltip text to show on mouse hover over the button

For password logins the following module settings are available:

TYPE = 'password' #identifies login method as using the password protocol
CREATE_PASSWORD_PROMPT - required, string, text to be displayed in the UI
CHANGE_PASSWORD_PROMPT - required, string, text to be displayed in the UI
EXTRA_TOKEN_NAME - required, string, text to be displayed above the login form
check_password - required, function, returns boolean, takes login name and password as parameters

If you have doubts about your own implementation of OpenID and especially OAuth and OAuth2 logins, please have a look into the file askbot/deps/django_authopenid/ (This does need to be split into per-protocol files, but as of version 0.7.50 that code lives there).

For OpenID logins the following setting is available:

TYPE - required, string, 'openid-direct'|'openid-username', use the last value if username is required beforehand)
OPENID_ENDPOINT - openid endpoint url, if TYPE='openid-username'
EXTRA_TOKEN_NAME - only for TYPE='openid-username', string, text to show above the user name input

For OAuth (version 1) logins the following settings are available, all are required:

TYPE = 'oauth'
OAUTH_CONSUMER_KEY - this and the following four parameters url string values
oauth_get_user_id_function - function, returns remote user id, parameter dictionary returned by 
the access token request (using the `oauth2` module - not to be confused with the OAuth2 
protocol as this module is actually OAuth1, but the name is confusing

See examples in `askbot/deps/django_authopenid/ ` for the Twitter and LinkedIn login implementations.

For AOuth2 logins the following settings are available:

TYPE = 'oauth2'
oauth_get_user_id_function - required, function, returns remote user id, 
                                             parameter - instance of `sanction.client.Client`
                                             after the request token is obtained
response_parser - required, parser function for the `sanction.client.Client.request_token` call
token_transport - required, `token_transport` parameter of the `sanction.client.Client` initialization

See examples in `askbot/deps/django_authopenid/` (e.g. Facebook or Google+ login methods)
edit flag offensive delete link more


Hi, I am trying to setup a custom oauth2 provider but can't seem to figure out how. can you please give more details and a sample code to do that ? btw i am new to askbot and django thanks

mtrachli gravatar imagemtrachli ( 2014-04-29 11:27:13 -0500 )edit

There isn't any implementation of this? Not a single pull request on Github to enable OAuth?

pnascimento gravatar imagepnascimento ( 2014-11-16 10:58:57 -0500 )edit

@pnascimento@mtrachli, please have a look, updated the answer.

Evgeny gravatar imageEvgeny ( 2014-11-16 11:55:28 -0500 )edit

@Evgeny enabling this custom module... "deactivates" local signin and OAuth as well... It fails because the providers returned by get_enabled_login_providers() from deps/django_authopenid/ does not contain the new module, and for some reason ignores or does not comply with local login

pnascimento gravatar imagepnascimento ( 2014-11-21 11:56:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-01-17 18:17:43 -0500

Seen: 6,084 times

Last updated: Nov 16 '14