Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruel/google-token-erlang
Google ID token verifier for Erlang
https://github.com/ruel/google-token-erlang
erlang google-authentication google-id-token google-token jwt-token otp
Last synced: 28 days ago
JSON representation
Google ID token verifier for Erlang
- Host: GitHub
- URL: https://github.com/ruel/google-token-erlang
- Owner: ruel
- License: mit
- Created: 2016-10-12T15:56:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-02T10:26:32.000Z (over 6 years ago)
- Last Synced: 2024-09-28T13:04:19.935Z (about 1 month ago)
- Topics: erlang, google-authentication, google-id-token, google-token, jwt-token, otp
- Language: Erlang
- Size: 14.6 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-erlang - google-token-erlang - Google ID token verifier for Erlang. (Third Party APIs)
README
# Google ID Token Verifier - Erlang
[![Build Status](https://travis-ci.org/ruel/google-token-erlang.svg?branch=master)](https://travis-ci.org/ruel/google-token-erlang) [![Hex.pm](https://img.shields.io/hexpm/v/google_token.svg)](https://hex.pm/packages/google_token)
An Erlang application that verifies the integrity of Google ID tokens
in accordance with [Google's criterias](https://developers.google.com/identity/sign-in/web/backend-auth).Google ID tokens are JWT web tokens passed by clients applications who
authenicated to [Google Identity Platform](https://developers.google.com/identity/protocols/OpenIDConnect)## OTP Version
**Required**: OTP 18 and later
## Setup
This application can be downloaded as a dependency from [Hex](https://hex.pm/packages/google_token)
```erlang
{deps, [
{google_token, "1.0.5"}
]}.
```Start **google_token** in your application's `.app.src` file
```erlang
{applications, [
kernel,
stdlib,
crypto,
ssl,
inets,
google_token
]}.
```> **NOTE**: The applications **crypto**, **ssl**, and **inets** must be started
first## Usage
Once started, **google_token** can be used by calling either `validate/1` or
`validate/2````erlang
IdToken = <<"eyJhbGciOiJSUzI1NiIsImtpZCI6IjcxMjY3OWMzMzVmMWQyZGIxM2FkZTQ0N2NlYjY2NThkM2QwZWExZWIifQ....">>,
{valid, Claims} = google_token:validate(IdToken).
```It's necessary to check the `aud` claim against your own client ID. You can
do this manually by yourself, or you can pass a list of IDs as the second
parameter of `validate/2````erlang
IdToken = <<"eyJhbGciOiJSUzI1NiIsImtpZCI6IjcxMjY3OWMzMzVmMWQyZGIxM2FkZTQ0N2NlYjY2NThkM2QwZWExZWIifQ....">>,
Ids = [<<"...apps.googleusercontent.com">>],
{valid, Claims} = google_token:validate(IdToken, Ids).
```Implementation based on: https://developers.google.com/identity/sign-in/web/backend-auth