flickr_authentication 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .rvmrc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in flickr_authentication.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Stephen Schor
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # FlickrAuthentication
2
+
3
+ A library for authentication your application via Flickr's API.
4
+ It uses the wonderful [flickraw](http://hanklords.github.io/flickraw/) library.
5
+
6
+ ## Resources
7
+
8
+ * [Applying for a Flickr API](http://www.flickr.com/services/apps/create/apply)
9
+ * [Flickr API documentation](http://www.flickr.com/services/api/)
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ flickr_authentication = FlickrAuthentication.new(key: "YOURKEYHERE", shared_secret: "APPSSHAREDSECRET", auth_file: "path/to/file/where/credentials/are/stored")
15
+ flickr = flickr_authentication.authenticate
16
+ #flickr is defined by flickraw
17
+ ```
18
+
19
+ For more example usage see the code for [flickr_airlift](https://github.com/nodanaonlyzuul/flickr_airlift) and [flickr_cli](https://github.com/nodanaonlyzuul/flickr_cli).
20
+
21
+ ## Contributing
22
+
23
+ 1. Fork it
24
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
25
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
26
+ 4. Push to the branch (`git push origin my-new-feature`)
27
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'flickr_authentication/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flickr_authentication"
8
+ spec.version = FlickrAuthentication::VERSION
9
+ spec.authors = ["Stephen Schor"]
10
+ spec.email = ["beholdthepanda@gmail.com"]
11
+ spec.description = %q{A library that simplifies the authentication and storing of credentials for applicartions that use the Flickr API}
12
+ spec.summary = %q{A library that simplifies the authentication and storing of credentials for applicartions that use the Flickr API}
13
+ spec.homepage = "https://github.com/nodanaonlyzuul/flickr_authentication"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency('launchy', '0.4.0')
22
+ spec.add_dependency('flickraw', '0.8.4')
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,3 @@
1
+ class FlickrAuthentication
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,52 @@
1
+ require "flickr_authentication/version"
2
+ require 'flickraw'
3
+ require 'launchy'
4
+
5
+ class FlickrAuthentication
6
+
7
+ attr_accessor :key, :shared_secret, :auth_file
8
+
9
+ def initialize(options = {})
10
+ @key = options[:key]
11
+ @shared_secret = options[:shared_secret]
12
+ @auth_file = options[:auth_file]
13
+ end
14
+
15
+ def authenticate
16
+ FlickRaw.api_key = key
17
+ FlickRaw.shared_secret = shared_secret
18
+
19
+ if File.exists?(auth_file)
20
+ puts "authenticating with #{auth_file}"
21
+ data = YAML.load_file(auth_file)
22
+ auth = flickr.auth.checkToken :auth_token => data["api_token"]
23
+ else
24
+ frob = flickr.auth.getFrob
25
+ auth_url = FlickRaw.auth_url :frob => frob, :perms => "write"
26
+
27
+ puts " "
28
+ puts "opening your browser..."
29
+ sleep 1
30
+ puts "Come back and press Enter when you are finished"
31
+ sleep 2
32
+ Launchy.open(auth_url)
33
+
34
+ STDIN.getc
35
+
36
+ # Authentication
37
+ auth = flickr.auth.getToken :frob => frob
38
+ login = flickr.test.login
39
+
40
+ puts auth.token
41
+
42
+ require 'yaml'
43
+ data = {}
44
+ data["api_token"] = auth.token
45
+ File.open(auth_file, "w"){|f| YAML.dump(data, f) }
46
+ end
47
+
48
+ flickr #return the flickr object
49
+
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flickr_authentication
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stephen Schor
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: launchy
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: flickraw
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.8.4
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: A library that simplifies the authentication and storing of credentials
79
+ for applicartions that use the Flickr API
80
+ email:
81
+ - beholdthepanda@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - flickr_authentication.gemspec
92
+ - lib/flickr_authentication.rb
93
+ - lib/flickr_authentication/version.rb
94
+ homepage: https://github.com/nodanaonlyzuul/flickr_authentication
95
+ licenses:
96
+ - MIT
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 1.8.24
116
+ signing_key:
117
+ specification_version: 3
118
+ summary: A library that simplifies the authentication and storing of credentials for
119
+ applicartions that use the Flickr API
120
+ test_files: []