SWI-Prolog code for "Login with Google"

This pack deals with "Login With Google" using OpenID Connect (OAuth 2.0 for Login). The code is partially based on pl-oauth2client-for-google

To run the code

  1. Follow these steps to create a Google project and get
  2. Edit demo/test.pl, fill in the client id and client secret. Start Prolog with demo/test.pl and run the command below to start the server.
    ?- server.
  3. Go to `http://localhost:3040` and hit the button. After logging in this should show a Prolog dict holding the Google profile information.

Requirements

Requires SWI-Prolog 7.1.30 or later (to be released, use version from GIT or nightly builds for Windows

Prolog files

demo/test.plShow source
pack.plShow source
prolog/google_client.pl  -- Sign in with Google OpenID ConnectShow source
create_user/1Called after login_existing_user/1 fails and the Google profile for the user has been fetched.Source
key/2This hook must provide the Google API keys.Source
login_existing_user/1Called after establishing the identify of the logged in user.Source
oauth_authenticate/3Step 2: redirect to Google for obtaining an authorization code.Source
openid_connect_discover/2True when Dicr represents The Discovery document.Source
prolog/jwt.pl  -- JSON Web Token libraryShow source
jwt/2True if Object is claimed in the JWT represented in String.Source