OAuth2Client

From PKC
Revision as of 03:49, 29 April 2021 by BenKoo>Admin
Jump to navigation Jump to search

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:

  1. Login to your Github.com account.
  2. Go to your settings, and navigate to create new OAuth Applications. The link[1] is shown.
  3. 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.
  4. Capture the Client ID and Secret.
  5. Make sure that you have MW-OAuth2Client package already installed in your MediaWiki's /extensions directory.
  6. Append the following the text to your LocalSettings.php
wfLoadExtension( 'MW-OAuth2Client' );
$wgOAuth2Client['client']['id'] = "ALPHA NUMERICAL STRING REPRESENTING CLIENT ID";
$wgOAuth2Client['client']['secret'] = "ALPHA NUMERICAL STRING REPRESENTING CLIENT 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



References