Class: Yt::Auth
- Inherits:
-
Object
- Object
- Yt::Auth
- Defined in:
- lib/yt/auth.rb,
lib/yt/auth/version.rb
Overview
Provides methods to authenticate a user with the Google OAuth flow.
Constant Summary collapse
- VERSION =
Returns the SemVer-compatible gem version.
'0.2.3'
Instance Method Summary collapse
-
#access_token ⇒ String
The access token of an authenticated Google account.
-
#email ⇒ String
The email of an authenticated Google account.
-
#initialize(options = {}) ⇒ Auth
constructor
A new instance of Auth.
-
#url ⇒ String
The URL where to authenticate with a Google account.
Constructor Details
#initialize(options = {}) ⇒ Auth
Returns a new instance of Auth.
16 17 18 19 20 |
# File 'lib/yt/auth.rb', line 16 def initialize( = {}) @redirect_uri = [:redirect_uri] @code = [:code] @refresh_token = [:refresh_token] end |
Instance Method Details
#access_token ⇒ String
Returns the access token of an authenticated Google account.
36 37 38 |
# File 'lib/yt/auth.rb', line 36 def access_token tokens['access_token'] end |
#email ⇒ String
Returns the email of an authenticated Google account.
31 32 33 |
# File 'lib/yt/auth.rb', line 31 def email profile['email'] end |
#url ⇒ String
Returns the URL where to authenticate with a Google account.
23 24 25 26 27 28 |
# File 'lib/yt/auth.rb', line 23 def url host = 'accounts.google.com' path = '/o/oauth2/auth' query = URI.encode_www_form url_params URI::HTTPS.build(host: host, path: path, query: query).to_s end |