Skip to content
Browse files

Merge pull request #2 from deviantech/master

Fixing auth by token
  • Loading branch information...
2 parents 15a5b28 + a7c78d5 commit 492c43263741ee64f5cf6cc2dbe49e62b0ce5dde Chris Le committed
Showing with 14 additions and 11 deletions.
  1. +2 −1 .gitignore
  2. +0 −5 .rvmrc
  3. +8 −0 README.md
  4. +0 −1 gattica.gemspec
  5. +4 −4 lib/gattica/engine.rb
View
3 .gitignore
@@ -2,4 +2,5 @@
github-test.rb
examples/active_example.rb
examples/.DS_Store
-.idea
+.idea
+.rvmrc
View
5 .rvmrc
@@ -1,5 +0,0 @@
-if [[ -s "~/.rvm/environments/ruby-1.9.2-p180@gattica" ]] ; then
- . "~/.rvm/environments/ruby-1.9.2-pl180@gattica"
-else
- rvm --create use "1.9.2@gattica"
-fi
View
8 README.md
@@ -1,3 +1,11 @@
+This Fork
+=======
+Deviantech's fork of the Gattica gem has the following modifications:
+
+* Authentication by token actually works
+
+-------
+
Gattica
=======
Gattica is an easy to use Gem for getting data from the Google Analytics API.
View
1 gattica.gemspec
@@ -17,7 +17,6 @@ Gem::Specification.new do |s|
"README.md"
]
s.files = [
- ".rvmrc",
"Gemfile",
"LICENSE",
"README.md",
View
8 lib/gattica/engine.rb
@@ -251,7 +251,7 @@ def create_http_connection
@http = Net::HTTP.new(Settings::SERVER, port)
@http.use_ssl = Settings::USE_SSL
@http.set_debug_output $stdout if @options[:debug]
- @http.read_timeout = @options[:timeout] if defined? @options[:timeout]
+ @http.read_timeout = @options[:timeout] if @options[:timeout]
end
# Sets instance variables from options given during initialization and
@@ -268,12 +268,12 @@ def handle_init_options(options)
# If the authorization is a email and password then create User objects
# or if it's a previous token, use that. Else, raise exception.
def check_init_auth_requirements
- if ((defined? @options[:email]) && (defined? @options[:password]))
+ if @options[:token].to_s.length > 200 # Not sure actual required length, but mine's 267
+ self.token = @options[:token]
+ elsif @options[:email] && @options[:password]
@user = User.new(@options[:email], @options[:password])
@auth = Auth.new(@http, user)
self.token = @auth.tokens[:auth]
- elsif (defined? @options[:token])
- self.token = @options[:token]
else
raise GatticaError::NoLoginOrToken, 'An email and password or an authentication token is required to initialize Gattica.'
end

0 comments on commit 492c432

Please sign in to comment.
Something went wrong with that request. Please try again.