0.01
No release in over 3 years
Low commit activity in last 3 years
Apple Sign In Token utilities; parse and check validity of token
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1.4
~> 1.3.0
~> 2.1.2
~> 12.3.3
~> 3.0

Runtime

~> 0.17.3
~> 2.2.1
 Project Readme

AppleIdToken

Gem Version Build Status Maintainability

This gem is a simple wrapper around Apple Sign In to validate provided tokens from https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens. You can also send tokens provided by official Apple library for iOS and Android applications.

We make use of JWT Ruby gem -> https://github.com/jwt/ruby-jwt to decode token provided by Apple and also it makes all the validations mentioned here -> https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/verifying_a_user to ensure integrity of provided token.

Installation

Add this line to your application's Gemfile:

gem 'apple_id_token'

And then execute:

$ bundle

Or install it yourself as:

$ gem install apple_id_token

Usage

To make use of the gem, just call .validate method of AppleIdToken::Validator. You need to provide token issued by Apple and also your APP_ID generated here -> https://help.apple.com/developer-account/#/devde676e696 as audience.

validator = AppleIdToken::Validator
begin
  payload = validator.validate(token: token, aud: audience)
  user_id = payload['sub']
  email = payload['email']
rescue AppleIdToken::PublicKeysError => e
  report "Provided keys are invalid: #{e}"
rescue AppleIdToken::ValidationError => e
  report "Cannot validate: #{e}"
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/PexegoUva/rails_apple_signin