README.md in google_sign_in-1.1.2 vs README.md in google_sign_in-1.2.0

- old
+ new

@@ -62,11 +62,21 @@ end ``` **⚠️ Important:** Take care to protect your client secret from disclosure to third parties. +9. (Optional) The callback route can be configured using: +```ruby +# config/initializers/google_sign_in.rb +Rails.application.configure do + config.google_sign_in.root = "my_own/google_sign_in_route" +end +``` + +Which would make the callback `/my_own/google_sign_in_route/callback`. + ## Usage This gem provides a `google_sign_in_button` helper. It generates a button which initiates Google sign-in: ```erb @@ -78,11 +88,12 @@ Sign in with my <%= image_tag('google_logo.png', alt: 'Google') %> account <% end %> ``` The `proceed_to` argument is required. After authenticating with Google, the gem redirects to `proceed_to`, providing -a Google ID token in `flash[:google_sign_in_token]`. Your application decides what to do with it: +a Google ID token in `flash[:google_sign_in][:id_token]` or an [OAuth authorizaton code grant error](https://tools.ietf.org/html/rfc6749#section-4.1.2.1) +in `flash[:google_sign_in][:error]`. Your application decides what to do with it: ```ruby # config/routes.rb Rails.application.routes.draw do # ... @@ -106,12 +117,15 @@ end end private def authenticate_with_google - if flash[:google_sign_in_token].present? - User.find_by google_id: GoogleSignIn::Identity.new(flash[:google_sign_in_token]).user_id + if id_token = flash[:google_sign_in][:id_token] + User.find_by google_id: GoogleSignIn::Identity.new(id_token).user_id + elsif error = flash[:google_sign_in][:error] + logger.error "Google authentication error: #{error}" + nil end end end ``` @@ -140,9 +154,13 @@ * `avatar_url` * `locale` * `hosted_domain`: The user’s hosted G Suite domain, provided only if they belong to a G Suite. + +* `given_name`: The user's given name. + +* `last_name`: The user's last name. ## Security For information on our security response procedure, see [SECURITY.md](SECURITY.md).