Extension:GoogleLogin/PreAuthManager

The GoogleLogin extension allows wiki users to login with their Google Accounts. The extension uses Google API to request user data. If the user logged in first time, the extension allows to create a user with the Google e-mail-address and Google username (or given name, or an own name).

Requirements
To use this extension you need:
 * MediaWiki 1.23+
 * MySQL (no PostgreSQL or SQLite support for now!)
 * PHP 5.3+
 * Google Developer Access
 * Google+ API access
 * API Credentials for Webapplication (Client ID and Client Secret)

Configuration
The extension provides two configuration variables to set the Client ID and Client Secret (you get this pair in Google Developer Console).

Settings in Google Developer Console
To use this extension you need a Google developer account and access to the developer console. This is a simple (a very simple!) step-by-step guide (use Step 1 of the official step-by-step example with these settings):
 * 1) Open Google developer console
 * 2) Read and accept the terms of service
 * 3) Create your first project
 * 4) Go to APIS & AUTH
 * 5) Enable Google+ API (read and accept the terms)
 * 6) Go to Credentials
 * 7) In Section OAuth2 click Create new Client ID
 * 8) Select as Web application as APPLICATION TYPE, as Authorized JavaScript origins type in your domain name (no wildcards and directories allowed!)
 * 9) Type in your Authorized redirect URI like this example:
 * If your domain is example.com and you have installed MediaWiki in Root of your domain, the redirect URI is as follows: http://example.com/index.php/Special:GoogleLogin
 * 1) Click create and copy the Client ID and Client Secret to the configuration variables in LocalSettings.php

FAQ
"Special:GoogleLogin" or (in German as example) "Spezial:Mit_Google_anmelden"

The allowed redirect URI in Google developer console must be in content language. So, if your wiki has content language German, then type in "Spezial:Mit_Google_anmelden" and not "Special:GoogleLogin". If you used the wrong language, all Authentication requests will fail with redirect uri mismatch.

Debug
Normally, you can see the error message on all generic error pages. Sometimes there are Internal Errors, called Exceptions. In this case, please add $wgShowExceptionDetails with value true in LocalSettings.php to see the complete Exception message. For a support request, please provide always the lines of the Exception.

What can this extension do
With the database update, the extension will create a new table called prefix_user_google_user which contains the needed connection between the wiki users and Google accounts. It stores only the Google UserId and the Wiki UserId.

If a user calls the special page GoogleLogin, he will instantly redirected to Google Authentication request to give your application access to some user information stored by Google. The user must accept this request (or he can not use the login with Google). After accepting, the user has the possibility, if he isn't logged in as a wiki user, to create a new account. The username he can choose self or choose one of the suggestions, based on the Google user name and given name (if one s free and createable). If the chosen username is creatable (free, valid and not blocked), a new user with the username and the Google-Mail as e-mail-address will be created and linked to the Google Account.

If the user is logged in (means: he has already a wiki account) he can link this account with the Google account, this the user must do only once. If the connection is created, the user will be able to login simply by clicking Login with Google button on Special:Login.

If the wiki account and Google account is connected, the user can, if he navigates to "Special:GoogleLogin", unlink his account and Google account.

Google API PHP Client
This Extension uses the Google API PHP Client (included), distributed under the Apache 2.0 License. The Client can be downloaded from GitHub.