Skip to content

Commit c5f4600

Browse files
committed
Update docs and examples
1 parent 4c14af8 commit c5f4600

2 files changed

Lines changed: 15 additions & 22 deletions

File tree

README.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
Strategy to authenticate with Google via OAuth2 in OmniAuth.
66

7-
Get your API key at: https://code.google.com/apis/console/ Note the Client ID and the Client Secret.
7+
Get your API key at: https://console.cloud.google.com Note the Client ID and the Client Secret.
88

9-
For more details, read the Google docs: https://developers.google.com/accounts/docs/OAuth2
9+
For more details, read the Google docs: https://developers.google.com/identity/protocols/oauth2
1010

1111
## Installation
1212

@@ -20,7 +20,7 @@ Then `bundle install`.
2020

2121
## Google API Setup
2222

23-
* Go to 'https://console.developers.google.com'
23+
* Go to 'https://console.cloud.google.com'
2424
* Select your project.
2525
* Go to Credentials, then select the "OAuth consent screen" tab on top, and provide an 'EMAIL ADDRESS' and a 'PRODUCT NAME'
2626
* Wait 10 minutes for changes to take effect.
@@ -76,11 +76,11 @@ You can configure several options, which you pass in to the `provider` method vi
7676

7777
* `hd`: (Optional) Limit sign-in to a particular Google Apps hosted domain. This can be simply string `'domain.com'` or an array `%w(domain.com domain.co)`. More information at: https://developers.google.com/accounts/docs/OpenIDConnect#hd-param
7878

79-
* `jwt_leeway`: Number of seconds passed to the JWT library as leeway. Defaults to 60 seconds. Note this only works if you use jwt 2.1, as the leeway option was removed in later versions.
79+
* `jwt_leeway`: Number of seconds passed to the JWT library as leeway. Defaults to 60 seconds.
8080

8181
* `skip_jwt`: Skip JWT processing. This is for users who are seeing JWT decoding errors with the `iat` field. Always try adjusting the leeway before disabling JWT processing.
8282

83-
* `login_hint`: When your app knows which user it is trying to authenticate, it can provide this parameter as a hint to the authentication server. Passing this hint suppresses the account chooser and either pre-fill the email box on the sign-in form, or select the proper session (if the user is using multiple sign-in), which can help you avoid problems that occur if your app logs in the wrong user account. The value can be either an email address or the sub string, which is equivalent to the user's Google+ ID.
83+
* `login_hint`: When your app knows which user it is trying to authenticate, it can provide this parameter as a hint to the authentication server. Passing this hint suppresses the account chooser and either pre-fill the email box on the sign-in form, or select the proper session (if the user is using multiple sign-in), which can help you avoid problems that occur if your app logs in the wrong user account. The value can be either an email address or the `sub` string (the user's unique Google ID).
8484

8585
* `include_granted_scopes`: If this is provided with the value true, and the authorization request is granted, the authorization will include any previous authorizations granted to this user/application combination for other scopes. See Google's [Incremental Authorization](https://developers.google.com/accounts/docs/OAuth2WebServer#incrementalAuth) for additional details.
8686

@@ -121,7 +121,7 @@ Here's an example of an authentication hash available in the callback by accessi
121121
"last_name" => "Smith",
122122
"image" => "https://lh4.googleusercontent.com/photo.jpg",
123123
"urls" => {
124-
"google" => "https://plus.google.com/+JohnSmith"
124+
"google" => "https://profiles.google.com/100000000000000000000"
125125
}
126126
},
127127
"credentials" => {
@@ -148,7 +148,7 @@ Here's an example of an authentication hash available in the callback by accessi
148148
"name" => "John Smith",
149149
"given_name" => "John",
150150
"family_name" => "Smith",
151-
"profile" => "https://plus.google.com/+JohnSmith",
151+
"profile" => "https://profiles.google.com/100000000000000000000",
152152
"picture" => "https://lh4.googleusercontent.com/photo.jpg?sz=50",
153153
"email" => "john@example.com",
154154
"email_verified" => "true",
@@ -227,14 +227,7 @@ end
227227
For your views you can login using:
228228

229229
```erb
230-
<%# omniauth-google-oauth2 1.0.x uses OmniAuth 2 and requires using HTTP Post to initiate authentication: %>
231230
<%= link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path, method: :post %>
232-
233-
<%# omniauth-google-oauth2 prior 1.0.0: %>
234-
<%= link_to "Sign in with Google", user_google_oauth2_omniauth_authorize_path %>
235-
236-
<%# Devise prior 4.1.0: %>
237-
<%= link_to "Sign in with Google", user_omniauth_authorize_path(:google_oauth2) %>
238231
```
239232

240233
An overview is available at https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
@@ -365,7 +358,7 @@ OmniAuth.config.full_host = Rails.env.production? ? 'https://domain.com' : 'http
365358

366359
## License
367360

368-
Copyright (c) 2018 by Josh Ellithorpe
361+
Copyright (c) 2018-2026 by Josh Ellithorpe
369362

370363
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
371364

examples/omni_auth.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22

33
# Google's OAuth2 docs. Make sure you are familiar with all the options
44
# before attempting to configure this gem.
5-
# https://developers.google.com/accounts/docs/OAuth2Login
5+
# https://developers.google.com/identity/protocols/oauth2
66

77
Rails.application.config.middleware.use OmniAuth::Builder do
88
# Default usage, this will give you offline access and a refresh token
99
# using default scopes 'email' and 'profile'
1010
#
11-
provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], scope: 'email, profile'
11+
provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], scope: 'email, profile'
1212

1313
# Custom redirect_uri
1414
#
15-
# provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], scope: 'email, profile', redirect_uri: 'https://localhost:3000/redirect'
15+
# provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], scope: 'email, profile', redirect_uri: 'https://localhost:3000/redirect'
1616

1717
# Manual setup for offline access with a refresh token.
1818
#
19-
# provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], access_type: 'offline'
19+
# provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], access_type: 'offline'
2020

21-
# Custom scope supporting youtube. If you are customizing scopes, remember
21+
# Custom scope supporting YouTube. If you are customizing scopes, remember
2222
# to include the default scopes 'email' and 'profile'
2323
#
24-
# provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], scope: 'http://gdata.youtube.com, email, profile, plus.me'
24+
# provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], scope: 'https://www.googleapis.com/auth/youtube.readonly, email, profile'
2525

2626
# Custom scope for users only using Google for account creation/auth and do not require a refresh token.
2727
#
28-
# provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], access_type: 'online', prompt: ''
28+
# provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], access_type: 'online', prompt: ''
2929
end

0 commit comments

Comments
 (0)