Facebook, Google OAuth2.0 . , OAuth2.0, OmniAuth , , .
OAuth2.0, OmniAuth
, , URL- , .
: URL , (, Facebook, Google ..). , , ( ).
, , ?
, . , , , . , , , :
- SSL (.. HTTPS). .
- , , .
- , .
, / , , , .
.
OmniAuth . :
gem 'httplog', group: :development
httplog. log/development.log. :
HttpLog.options[:logger] = Rails.logger if Rails.env.development?
Rails :
bundle install
rails s
:
tail -f log/development.log
. , , (Started GET "/auth/google_oauth2/callback?state=1) - :
[httplog] Connecting: accounts.google.com:443
[httplog] Sending: POST http://accounts.google.com:443/o/oauth2/token
[httplog] Data: client_id=123412341234-1234h1234h1234h1234h.apps.googleusercontent.com&client_secret=12341234123412341234&code=123412341234123412341234&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fyourapp.domain.com%2Fauth%2Fgoogle_oauth2%2Fcallback
....
[httplog] Response:
{
"access_token" : "123412341234123412341234",
"token_type" : "Bearer",
"expires_in" : 3599,
...
}
, . OmniAuth , . :
[httplog] Connecting: www.googleapis.com:443
[httplog] Sending: GET http:
[httplog] Status: 200
[httplog] Response:
{
"kind": "plus#personOpenIdConnect",
"gender": "male",
"sub": "1234123412341234",
"name": "Matt",
"given_name": "Matt",
...
}
, OmniAuth .
, , . httplog , !