Coder Social home page Coder Social logo

manifest / pal-google Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 236 KB

Pragmatic Authentication Library: Google workflows

License: MIT License

Makefile 1.86% Erlang 98.14%
erlang authentication authentication-strategy authentication-flow oauth2 oauth2-client oauth2-workflows oauth2-authcode google-oauth2-authcode web

pal-google's Introduction

Pragmatic Authentication Library: Google workflows

Collection of Google workflows for PAL.

1. Google Login (OAuth2 Authorization Code Grant) workflow

For details, read the Google documentation.

Options

You can configure the workflow by passing options below into pal:new/2 or pal:group/2 functions:

  • client_id (required) - The client ID obtained from the Developers Console.
  • client_secret (required) - The client secret obtained from the Developers Console.
  • redirect_uri (required) - The client redirection endpoint. After completing its interaction with the resource owner, the authorization server directs the resource owner's user-agent to this uri.
  • scope (optional) - The scope of the access request.
  • request_options (optional) - Options for the hackney HTTP client.
  • includes (optional) - Parts of authentication schema to be processed by the workflow. All by default, [uid, credentials, info, extra, rules].

Input Data

  • code - The authorization code.
  • state - The state was previously passed to the authentication provider.
  • error If the request fails due to a missing, invalid, or mismatching redirection URI, or if the client identifier is missing or invalid.

Authentication Schema

An successful execution of pal:authenticate/{2,3} function returns the authentication schema below.

#{access_token => <<"...">>, 
  token_type => <<"Bearer">>,
  expires_in => 3599,
  id_token => <<"...">>}

See a complete example with PAL and Cowboy HTTP server here.

2. Google OpenID User (an ID token validation) workflow

Options

You can configure the workflow by passing options below into pal:new/2 or pal:group/2 functions:

  • request_options (optional) - Options for the hackney HTTP client.
  • includes (optional) - Parts of authentication schema to be processed by the workflow. All by default, [uid, credentials, info, extra, rules].

Input Data

  • id_token (required) - An id token obtained using the pal_google_oauth2_authcode workflow.

Authentication Schema

An successful execution of pal:authenticate/{2,3} function returns the authentication schema below.

#{uid => <<"...">>,
  info =>
    #{email => <<"[email protected]">>}}

See a complete example with PAL and Cowboy HTTP server here.

3. Google+ User (user's profile data) workflow

Options

You can configure the workflow by passing options below into pal:new/2 or pal:group/2 functions:

  • request_options (optional) - Options for the hackney HTTP client.
  • includes (optional) - Parts of authentication schema to be processed by the workflow. All by default, [uid, credentials, info, extra, rules].

Input Data

  • access_token (required) - An access token obtained using the pal_google_oauth2_authcode workflow.

Authentication Schema

An successful execution of pal:authenticate/{2,3} function returns the authentication schema below.

#{uid => <<"...">>,
  info =>
    #{name => <<"John Doe">>,
      first_name => <<"John">>,
      last_name => <<"Doe">>,
      gender => <<"male">>,
      email => <<"[email protected]">>,
      image => <<"https://lh3.googleusercontent.com/...">>,
      uri => <<"https://plus.google.com/...">>}}

See a complete example with PAL and Cowboy HTTP server here.

License

The source code is provided under the terms of the MIT license.

pal-google's People

Contributors

manifest avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.