First time here? Check out the FAQ!

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

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
Fabien Meghazi's avatar
Fabien Meghazi
asked 2013-01-17 18:17:43 -0600
edit flag offensive 0 remove flag close merge delete


add a comment see more comments

1 Answer


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)
Evgeny's avatar
answered 2013-01-18 14:50:44 -0600, updated 2014-11-16 11:54:53 -0600
edit flag offensive 0 remove flag delete link


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's avatar mtrachli (2014-04-29 11:27:13 -0600) edit

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

pnascimento's avatar pnascimento (2014-11-16 10:58:57 -0600) edit

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

Evgeny's avatar Evgeny (2014-11-16 11:55:28 -0600) 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's avatar pnascimento (2014-11-21 11:56:06 -0600) edit
add a comment see more comments