omniauth-mendeley_oauth2 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +71 -0
- data/Rakefile +2 -0
- data/example/Gemfile +4 -0
- data/example/config.ru +29 -0
- data/lib/omniauth/mendeley/version.rb +5 -0
- data/lib/omniauth/strategies/mendeley.rb +55 -0
- data/lib/omniauth-mendeley.rb +2 -0
- data/omniauth-mendeley_oauth2.gemspec +20 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e896e344f5c7f1f988d20566512c160c5c3b025f
|
4
|
+
data.tar.gz: c5b56af8f8304bdc758c104ed8012f8e4fca9226
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ae1f6fdb0f14030269817be4544645e3147cb4b923fff82fe7d47f60fa1dcc724db1e9d229621c475d87b3acf0da7fc34c0e9de02c888722b1590b406b4c091f
|
7
|
+
data.tar.gz: 278f66de4e88550d47419e5292e2efd28ad84a6537323fdfff9c6e2a2afc9ee2f1324fcecf9490fa9512c94574804f37bef095170b1cc050b6fb35116ad71194
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# OmniAuth Mendeley
|
2
|
+
|
3
|
+
This is the unofficial [OmniAuth 1.0](https://github.com/intridea/omniauth) strategy for authenticating to Mendeley via OAuth2.
|
4
|
+
To use it, you'll need to sign up at [Mendeley.com](http://mendeley.com), sign in with given credentials
|
5
|
+
at [Mendeley Developers Page](http://dev.mendeley.com/) and then create an OAuth2 app.
|
6
|
+
|
7
|
+
## Basic Usage
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
use OmniAuth::Builder do
|
11
|
+
provider :mendeley, ENV['API_KEY'], ENV['API_SECRET']
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
## Authentication Hash
|
16
|
+
|
17
|
+
Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
{
|
21
|
+
"provider" => :mendeley,
|
22
|
+
"uid" => "asdvwsas-2382-29cc-552b-442dvd5q235ae",
|
23
|
+
"info" => {
|
24
|
+
"name" => "Alexander White",
|
25
|
+
"first_name" => "Alexander",
|
26
|
+
"last_name" => "White",
|
27
|
+
"email" => "your_mail@gmail.com",
|
28
|
+
"image" => "http://s3.amazonaws.com/mendeley-photos/awaiting.png",
|
29
|
+
"urls" => {
|
30
|
+
"mendeley" => "http://www.mendeley.com/profiles/alexander-white/"
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"credentials" => {
|
34
|
+
"token" => "long_string",
|
35
|
+
"refresh_token" => "long_string",
|
36
|
+
"expires_at" => 1403397662,
|
37
|
+
"expires" => true
|
38
|
+
},
|
39
|
+
"extra" => {
|
40
|
+
"raw_info" => {
|
41
|
+
"id" => "asdvwsas-2382-29cc-552b-442dvd5q235ae",
|
42
|
+
"first_name" => "Alexander",
|
43
|
+
"last_name" => "White",
|
44
|
+
"display_name" => "Alexander White",
|
45
|
+
"email" => "your_mail@gmail.com",
|
46
|
+
"link" => "http://www.mendeley.com/profiles/alexander-white/",
|
47
|
+
"academic_status" => "Student (Master)",
|
48
|
+
"discipline" => {
|
49
|
+
"name" => "Computer and Information Science"
|
50
|
+
},
|
51
|
+
"photo" => {
|
52
|
+
"standard" => "http://s3.amazonaws.com/mendeley-photos/awaiting.png",
|
53
|
+
"square" => "http://s3.amazonaws.com/mendeley-photos/awaiting_square.png"
|
54
|
+
},
|
55
|
+
"verified" => true,
|
56
|
+
"user_type" => "normal",
|
57
|
+
"created" => "2014-06-21T20:46:54.000Z"
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
The precise information available may depend on the permissions which you request.
|
64
|
+
|
65
|
+
|
66
|
+
## Supported Rubies
|
67
|
+
|
68
|
+
Tested with the following Ruby versions:
|
69
|
+
|
70
|
+
- MRI 2.1.0
|
71
|
+
|
data/Rakefile
ADDED
data/example/Gemfile
ADDED
data/example/config.ru
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'sinatra'
|
3
|
+
require 'omniauth-mendeley'
|
4
|
+
|
5
|
+
use Rack::Session::Cookie
|
6
|
+
|
7
|
+
# to register a Mendeley app sign up at http://mendeley.com/,
|
8
|
+
# then login with given credentials at http://dev.mendeley.com
|
9
|
+
|
10
|
+
MENDELEY_CONSUMER_KEY = 'your_app_key'
|
11
|
+
MENDELEY_CONSUMER_SECRET = 'your_app_secret'
|
12
|
+
|
13
|
+
use OmniAuth::Builder do
|
14
|
+
provider :mendeley, MENDELEY_CONSUMER_KEY, MENDELEY_CONSUMER_SECRET
|
15
|
+
end
|
16
|
+
|
17
|
+
class App < Sinatra::Base
|
18
|
+
get '/' do
|
19
|
+
"<a href='/auth/mendeley'>Sign in via Mendeley</a>"
|
20
|
+
end
|
21
|
+
|
22
|
+
get '/auth/:provider/callback' do
|
23
|
+
content_type 'text/plain'
|
24
|
+
info = request.env['omniauth.auth'].to_hash
|
25
|
+
MultiJson.dump(info).to_s
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
run App.new
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Mendeley < OmniAuth::Strategies::OAuth2
|
6
|
+
|
7
|
+
# http://dev.mendeley.com/html/authentication.html
|
8
|
+
# Mendeley currently supports only 'all' value
|
9
|
+
DEFAULT_SCOPE = 'all'
|
10
|
+
|
11
|
+
option :name, 'mendeley'
|
12
|
+
|
13
|
+
option :client_options, {
|
14
|
+
:site => 'https://mix.mendeley.com',
|
15
|
+
:token_path => '/oauth/token/',
|
16
|
+
:authorize_path => '/oauth/authorize/',
|
17
|
+
}
|
18
|
+
|
19
|
+
uid do
|
20
|
+
raw_info['id']
|
21
|
+
end
|
22
|
+
|
23
|
+
info do
|
24
|
+
{
|
25
|
+
:name => raw_info['display_name'],
|
26
|
+
:first_name => raw_info['first_name'],
|
27
|
+
:last_name => raw_info['last_name'],
|
28
|
+
:email => raw_info['email'],
|
29
|
+
:image => raw_info['photo']['standard'],
|
30
|
+
:urls => {
|
31
|
+
'mendeley' => raw_info['link']
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
extra do
|
37
|
+
{
|
38
|
+
'raw_info' => raw_info
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def raw_info
|
43
|
+
@raw_info ||= MultiJson.decode(access_token.get('/profiles/me').body)
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def authorize_params
|
48
|
+
super.tap do |params|
|
49
|
+
params[:scope] ||= DEFAULT_SCOPE
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../lib/omniauth/mendeley/version', __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
5
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.1'
|
6
|
+
gem.add_dependency 'multi_json'
|
7
|
+
|
8
|
+
gem.authors = ["Anton Chuchkalov"]
|
9
|
+
gem.email = ["a2new@yandex.ru"]
|
10
|
+
gem.description = %q{Unofficial Mendeley strategy for OmniAuth 1.2.1}
|
11
|
+
gem.summary = %q{Unofficial Mendeley strategy for OmniAuth 1.2.1}
|
12
|
+
gem.homepage = "https://github.com/hedgesky/omniauth-mendeley"
|
13
|
+
|
14
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.name = "omniauth-mendeley_oauth2"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = OmniAuth::Mendeley::VERSION
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-mendeley_oauth2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Chuchkalov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multi_json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Unofficial Mendeley strategy for OmniAuth 1.2.1
|
56
|
+
email:
|
57
|
+
- a2new@yandex.ru
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- README.md
|
63
|
+
- Rakefile
|
64
|
+
- example/Gemfile
|
65
|
+
- example/config.ru
|
66
|
+
- lib/omniauth-mendeley.rb
|
67
|
+
- lib/omniauth/mendeley/version.rb
|
68
|
+
- lib/omniauth/strategies/mendeley.rb
|
69
|
+
- omniauth-mendeley_oauth2.gemspec
|
70
|
+
homepage: https://github.com/hedgesky/omniauth-mendeley
|
71
|
+
licenses: []
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.2.2
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Unofficial Mendeley strategy for OmniAuth 1.2.1
|
93
|
+
test_files: []
|