OAuth2Client
Revision as of 08:33, 29 April 2021 by BenKoo>Benkoo
OAuth stands for Open Authentication, and OAuth2, is an abbreviation for Open Auth 2.0.
This article tries to explain how to install OAuth2Client for MediaWiki.
Github as the OAuth Server
For the purpose of getting started, Github.com will be used as the OAuth Service provider. The first step is to create an OAuth Application on Github. One should already have an account on Github. The process of how to create an OAuth application for your Github account can be found here[1]:
Please go through the following process:
- Login to your Github.com account.
- Go to your settings, and navigate to create new OAuth Applications. The link[1] is shown.
- You will be prompted with an interface that gives your a new Client ID and ask you to name your application, upload a logo for the application, and you will use the interface to generate a Client Secret.
- Capture the Client ID and Secret.
- Make sure that you have MW-OAuth2Client package already installed in your MediaWiki's /extensions directory.
- Append the following the text to your LocalSettings.php
wfLoadExtension( 'MW-OAuth2Client' );
$wgOAuth2Client['client']['id'] = "alpha_numerical_strings_representing_client_id";
$wgOAuth2Client['client']['secret'] = "alpha_numerical_strings_representing_secret";
$wgOAuth2Client['configuration']['authorize_endpoint'] = 'https://github.com/login/oauth/authorize'; // Authorization URL
$wgOAuth2Client['configuration']['access_token_endpoint'] = 'https://github.com/login/oauth/access_token'; // Token URL
$wgOAuth2Client['configuration']['api_endpoint'] = 'https://api.github.com/user'; // URL to fetch user JSON
$wgOAuth2Client['configuration']['redirect_uri'] = "http://localhost:9352/index.php/Special:OAuth2Client/callback";
$wgOAuth2Client['configuration']['username'] = 'login'; // JSON path to username
$wgOAuth2Client['configuration']['email'] = 'email'; // JSON path to email
$wgOAuth2Client['configuration']['scopes'] = 'openid email profile'; //Permissions
$wgOAuth2Client['configuration']['service_name'] = 'Oauth Registry'; // the name of your service
$wgOAuth2Client['configuration']['service_login_link_text'] = 'OAuth-Github'; // the text of the login link
Caveat
For participants who wants to use OAuth features on Github, just go to http://github.com/xlp0/PKC, and download the code base. It should[2] work with your local application, as long as the redirect_uri is set to
http://localhost:9352/index.php/Special:OAuth2Client/callback
as shown above.
Notes
References
- ↑ 1.0 1.1 https://github.com/settings/applications/new
- ↑ It should work because the client ID and client secret should match all the required settings.