omniauth-linkedin-oauth2-cwd 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.idea/inspectionProfiles/Project_Default.xml +153 -0
- data/.idea/vcs.xml +6 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +84 -0
- data/Rakefile +6 -0
- data/example/Gemfile +4 -0
- data/example/config.ru +31 -0
- data/lib/omniauth-linkedin-oauth2.rb +2 -0
- data/lib/omniauth-linkedin-oauth2/version.rb +5 -0
- data/lib/omniauth/strategies/linkedin.rb +82 -0
- data/omniauth-linkedin-oauth2.gemspec +29 -0
- data/spec/omniauth/strategies/linkedin_spec.rb +121 -0
- data/spec/spec_helper.rb +20 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 815ff115f30d23e99e0d5ab6ed0954e169593857
|
4
|
+
data.tar.gz: 2203e1be43a6e1ea9308b360308759fa12f14622
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15b070131e9ddf69a3f2188eb5d194f235a00090d22a29c06a037209311cb71edf3402116882555a0da35494012030cf86366201f22dad9d43eabb68f81249cb
|
7
|
+
data.tar.gz: bcf6a5262f8fb431e045cef5891fe29c8af25bde091a2a0405bdbaa0b538e79e0b4f594777cbd709eaffd6f49b8c1c1278be5d210f2d0922ac5613dc8e3afa1c
|
data/.gitignore
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
2
|
+
<profile version="1.0">
|
3
|
+
<option name="myName" value="Project Default" />
|
4
|
+
<inspection_tool class="Annotator" enabled="false" level="ERROR" enabled_by_default="false" />
|
5
|
+
<inspection_tool class="AnonymousFunctionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
6
|
+
<inspection_tool class="AssignmentResultUsedJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
7
|
+
<inspection_tool class="AssignmentToForLoopParameterJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
8
|
+
<inspection_tool class="AssignmentToFunctionParameterJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
9
|
+
<inspection_tool class="BlockStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
10
|
+
<inspection_tool class="BreakStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
11
|
+
<inspection_tool class="BreakStatementWithLabelJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
12
|
+
<inspection_tool class="ChainedEqualityJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
13
|
+
<inspection_tool class="ChainedFunctionCallJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
14
|
+
<inspection_tool class="CheckDtdRefs" enabled="false" level="ERROR" enabled_by_default="false" />
|
15
|
+
<inspection_tool class="CheckTagEmptyBody" enabled="false" level="WARNING" enabled_by_default="false" />
|
16
|
+
<inspection_tool class="CheckXmlFileWithXercesValidator" enabled="false" level="ERROR" enabled_by_default="false" />
|
17
|
+
<inspection_tool class="ConditionalExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
18
|
+
<inspection_tool class="ConditionalExpressionWithIdenticalBranchesJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
19
|
+
<inspection_tool class="ConfusingFloatingPointLiteralJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
20
|
+
<inspection_tool class="ConfusingPlusesOrMinusesJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
21
|
+
<inspection_tool class="ConstantOnLHSOfComparisonJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
22
|
+
<inspection_tool class="ConstantOnRHSOfComparisonJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
23
|
+
<inspection_tool class="ContinueStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
24
|
+
<inspection_tool class="ContinueStatementWithLabelJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
25
|
+
<inspection_tool class="CssConvertColorToHexInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
26
|
+
<inspection_tool class="CssConvertColorToRgbInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
27
|
+
<inspection_tool class="CssMissingSemicolon" enabled="true" level="WARNING" enabled_by_default="true" />
|
28
|
+
<inspection_tool class="CucumberDuplicatedStep" enabled="false" level="ERROR" enabled_by_default="false" />
|
29
|
+
<inspection_tool class="CucumberExamplesColon" enabled="false" level="ERROR" enabled_by_default="false" />
|
30
|
+
<inspection_tool class="CucumberMissedExamples" enabled="false" level="ERROR" enabled_by_default="false" />
|
31
|
+
<inspection_tool class="CucumberStepDefinitionParameter" enabled="false" level="WARNING" enabled_by_default="false" />
|
32
|
+
<inspection_tool class="CucumberTableInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
33
|
+
<inspection_tool class="CucumberUndefinedStep" enabled="false" level="WARNING" enabled_by_default="false" />
|
34
|
+
<inspection_tool class="CyclomaticComplexityJS" enabled="true" level="WARNING" enabled_by_default="true">
|
35
|
+
<option name="m_limit" value="10" />
|
36
|
+
</inspection_tool>
|
37
|
+
<inspection_tool class="DebuggerStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
38
|
+
<inspection_tool class="DefaultNotLastCaseInSwitchJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
39
|
+
<inspection_tool class="DivideByZeroJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
40
|
+
<inspection_tool class="DocumentWriteJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
41
|
+
<inspection_tool class="DuplicateConditionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
42
|
+
<inspection_tool class="DynamicallyGeneratedCodeJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
43
|
+
<inspection_tool class="ES6Validation" enabled="true" level="WARNING" enabled_by_default="true" />
|
44
|
+
<inspection_tool class="EmptyCatchBlockJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
45
|
+
<inspection_tool class="EmptyFinallyBlockJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
46
|
+
<inspection_tool class="EmptyTryBlockJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
47
|
+
<inspection_tool class="EscapedMetaCharacter" enabled="true" level="WARNING" enabled_by_default="true" />
|
48
|
+
<inspection_tool class="Eslint" enabled="true" level="ERROR" enabled_by_default="true" />
|
49
|
+
<inspection_tool class="FlowJSCoverage" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
50
|
+
<inspection_tool class="FlowJSError" enabled="true" level="ERROR" enabled_by_default="true" />
|
51
|
+
<inspection_tool class="ForLoopReplaceableByWhileJS" enabled="true" level="WARNING" enabled_by_default="true">
|
52
|
+
<option name="m_ignoreLoopsWithoutConditions" value="false" />
|
53
|
+
</inspection_tool>
|
54
|
+
<inspection_tool class="ForLoopThatDoesntUseLoopVariableJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
55
|
+
<inspection_tool class="FunctionNamingConventionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
56
|
+
<option name="m_regex" value="[a-z][A-Za-z]*" />
|
57
|
+
<option name="m_minLength" value="4" />
|
58
|
+
<option name="m_maxLength" value="32" />
|
59
|
+
</inspection_tool>
|
60
|
+
<inspection_tool class="FunctionWithInconsistentReturnsJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
61
|
+
<inspection_tool class="FunctionWithMultipleLoopsJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
62
|
+
<inspection_tool class="FunctionWithMultipleReturnPointsJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
63
|
+
<inspection_tool class="GherkinBrokenTableInspection" enabled="false" level="ERROR" enabled_by_default="false" />
|
64
|
+
<inspection_tool class="GherkinMisplacedBackground" enabled="false" level="ERROR" enabled_by_default="false" />
|
65
|
+
<inspection_tool class="GjsLint" enabled="true" level="WARNING" enabled_by_default="true" />
|
66
|
+
<inspection_tool class="HtmlNonExistentInternetResource" enabled="true" level="WARNING" enabled_by_default="true" />
|
67
|
+
<inspection_tool class="IfStatementWithIdenticalBranchesJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
68
|
+
<inspection_tool class="IfStatementWithTooManyBranchesJS" enabled="true" level="WARNING" enabled_by_default="true">
|
69
|
+
<option name="m_limit" value="3" />
|
70
|
+
</inspection_tool>
|
71
|
+
<inspection_tool class="IncrementDecrementResultUsedJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
72
|
+
<inspection_tool class="InnerHTMLJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
73
|
+
<inspection_tool class="JSClassNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" />
|
74
|
+
<inspection_tool class="JSDeclarationsAtScopeStart" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
75
|
+
<inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
|
76
|
+
<inspection_tool class="JSLint" enabled="true" level="ERROR" enabled_by_default="true" />
|
77
|
+
<inspection_tool class="Jscs" enabled="true" level="ERROR" enabled_by_default="true" />
|
78
|
+
<inspection_tool class="LabeledStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
79
|
+
<inspection_tool class="LocalVariableNamingConventionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
80
|
+
<option name="m_regex" value="[a-z][A-Za-z]*" />
|
81
|
+
<option name="m_minLength" value="1" />
|
82
|
+
<option name="m_maxLength" value="32" />
|
83
|
+
</inspection_tool>
|
84
|
+
<inspection_tool class="MagicNumberJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
85
|
+
<inspection_tool class="NegatedConditionalExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
86
|
+
<inspection_tool class="NegatedIfStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
87
|
+
<inspection_tool class="NestedAssignmentJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
88
|
+
<inspection_tool class="NestedConditionalExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
89
|
+
<inspection_tool class="NestedFunctionCallJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
90
|
+
<inspection_tool class="NestedFunctionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
91
|
+
<option name="m_includeAnonymousFunctions" value="false" />
|
92
|
+
</inspection_tool>
|
93
|
+
<inspection_tool class="NestedSwitchStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
94
|
+
<inspection_tool class="NestingDepthJS" enabled="true" level="WARNING" enabled_by_default="true">
|
95
|
+
<option name="m_limit" value="5" />
|
96
|
+
</inspection_tool>
|
97
|
+
<inspection_tool class="NonBlockStatementBodyJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
98
|
+
<inspection_tool class="NonShortCircuitBooleanExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
99
|
+
<inspection_tool class="ObjectAllocationIgnoredJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
100
|
+
<inspection_tool class="OctalEscape" enabled="true" level="WARNING" enabled_by_default="true" />
|
101
|
+
<inspection_tool class="OverlyComplexArithmeticExpressionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
102
|
+
<option name="m_limit" value="6" />
|
103
|
+
</inspection_tool>
|
104
|
+
<inspection_tool class="OverlyComplexBooleanExpressionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
105
|
+
<option name="m_limit" value="3" />
|
106
|
+
</inspection_tool>
|
107
|
+
<inspection_tool class="ParameterNamingConventionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
108
|
+
<option name="m_regex" value="[a-z][A-Za-z]*" />
|
109
|
+
<option name="m_minLength" value="1" />
|
110
|
+
<option name="m_maxLength" value="32" />
|
111
|
+
</inspection_tool>
|
112
|
+
<inspection_tool class="ParametersPerFunctionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
113
|
+
<option name="m_limit" value="5" />
|
114
|
+
</inspection_tool>
|
115
|
+
<inspection_tool class="PlatformDetectionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
116
|
+
<inspection_tool class="ReplaceAssignmentWithOperatorAssignmentJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
117
|
+
<inspection_tool class="ReuseOfLocalVariableJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
118
|
+
<inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
|
119
|
+
<inspection_tool class="RubyLiteralArrayInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
120
|
+
<inspection_tool class="StandardJS" enabled="true" level="ERROR" enabled_by_default="true" />
|
121
|
+
<inspection_tool class="StatementsPerFunctionJS" enabled="true" level="WARNING" enabled_by_default="true">
|
122
|
+
<option name="m_limit" value="30" />
|
123
|
+
</inspection_tool>
|
124
|
+
<inspection_tool class="StringLiteralBreaksHTMLJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
125
|
+
<inspection_tool class="Stylelint" enabled="true" level="ERROR" enabled_by_default="true" />
|
126
|
+
<inspection_tool class="SwitchStatementWithNoDefaultBranchJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
127
|
+
<inspection_tool class="TailRecursionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
128
|
+
<inspection_tool class="TextLabelInSwitchStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
129
|
+
<inspection_tool class="ThreeNegationsPerFunctionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
130
|
+
<inspection_tool class="TypeScriptAccessibilityCheck" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
131
|
+
<inspection_tool class="TypeScriptCheckImport" enabled="false" level="ERROR" enabled_by_default="false" />
|
132
|
+
<inspection_tool class="TypeScriptPreferShortImport" enabled="false" level="WARNING" enabled_by_default="false" />
|
133
|
+
<inspection_tool class="TypeScriptUMDGlobal" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
134
|
+
<inspection_tool class="TypeScriptUnresolvedFunction" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
135
|
+
<inspection_tool class="TypeScriptUnresolvedVariable" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
136
|
+
<inspection_tool class="TypeScriptValidateJSTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
137
|
+
<inspection_tool class="TypeScriptValidateTypes" enabled="false" level="ERROR" enabled_by_default="false" />
|
138
|
+
<inspection_tool class="TypescriptExplicitMemberType" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
139
|
+
<inspection_tool class="UnusedCatchParameterJS" enabled="true" level="WARNING" enabled_by_default="true">
|
140
|
+
<option name="m_ignoreCatchBlocksWithComments" value="false" />
|
141
|
+
</inspection_tool>
|
142
|
+
<inspection_tool class="UnusedDefine" enabled="true" level="WARNING" enabled_by_default="true" />
|
143
|
+
<inspection_tool class="VoidExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
144
|
+
<inspection_tool class="XHTMLIncompatabilitiesJS" enabled="true" level="WARNING" enabled_by_default="true" />
|
145
|
+
<inspection_tool class="XmlDuplicatedId" enabled="false" level="ERROR" enabled_by_default="false" />
|
146
|
+
<inspection_tool class="XmlHighlighting" enabled="false" level="ERROR" enabled_by_default="false" />
|
147
|
+
<inspection_tool class="XmlInvalidId" enabled="false" level="ERROR" enabled_by_default="false" />
|
148
|
+
<inspection_tool class="XmlPathReference" enabled="false" level="ERROR" enabled_by_default="false" />
|
149
|
+
<inspection_tool class="XmlUnboundNsPrefix" enabled="false" level="WARNING" enabled_by_default="false" />
|
150
|
+
<inspection_tool class="XmlUnusedNamespaceDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
|
151
|
+
<inspection_tool class="XmlWrongRootElement" enabled="false" level="ERROR" enabled_by_default="false" />
|
152
|
+
</profile>
|
153
|
+
</component>
|
data/.idea/vcs.xml
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Décio Ferreira
|
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,84 @@
|
|
1
|
+
# OmniAuth LinkedIn OAuth2 Strategy
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/decioferreira/omniauth-linkedin-oauth2.png?branch=master)](https://travis-ci.org/decioferreira/omniauth-linkedin-oauth2)
|
4
|
+
|
5
|
+
A LinkedIn OAuth2 strategy for OmniAuth.
|
6
|
+
|
7
|
+
For more details, read the LinkedIn documentation: https://developer.linkedin.com/documents/authentication
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'omniauth-linkedin-oauth2'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install omniauth-linkedin-oauth2
|
22
|
+
|
23
|
+
## Upgrading
|
24
|
+
|
25
|
+
Previous versions of this gem used the provider name `:linkedin_oauth2`. In order to provide a cleaner upgrade path for users who were previously using the OAuth 1.0 omniauth adapter for LinkedIn [https://github.com/skorks/omniauth-linkedin], this has been renamed to just `:linkedin`.
|
26
|
+
|
27
|
+
Users who are upgrading from previous versions of this gem may need to update their Omniauth and/or Devise configurations to use the shorter provider name.
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
Register your application with LinkedIn to receive an API key: https://www.linkedin.com/secure/developer
|
32
|
+
|
33
|
+
This is an example that you might put into a Rails initializer at `config/initializers/omniauth.rb`:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
37
|
+
provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET']
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
You can now access the OmniAuth LinkedIn OAuth2 URL: `/auth/linkedin`.
|
42
|
+
|
43
|
+
## Granting Member Permissions to Your Application
|
44
|
+
|
45
|
+
With the LinkedIn API, you have the ability to specify which permissions you want users to grant your application.
|
46
|
+
For more details, read the LinkedIn documentation: https://developer.linkedin.com/documents/authentication
|
47
|
+
|
48
|
+
By default, omniauth-linkedin-oauth2 requests the following permissions:
|
49
|
+
|
50
|
+
'r_basicprofile r_emailaddress'
|
51
|
+
|
52
|
+
You can configure the scope option:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'], :scope => 'r_fullprofile r_emailaddress r_network'
|
56
|
+
```
|
57
|
+
|
58
|
+
## Profile Fields
|
59
|
+
|
60
|
+
When specifying which permissions you want to users to grant to your application, you will probably want to specify the array of fields that you want returned in the omniauth hash. The list of default fields is as follows:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-url', 'public-profile-url']
|
64
|
+
```
|
65
|
+
|
66
|
+
Here's an example of a possible configuration where the fields returned from the API are: id, email-address, first-name and last-name.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'], :fields => ['id', 'email-address', 'first-name', 'last-name']
|
70
|
+
```
|
71
|
+
|
72
|
+
To see a complete list of available fields, consult the LinkedIn documentation at: https://developer.linkedin.com/documents/profile-fields
|
73
|
+
|
74
|
+
## Other Options
|
75
|
+
|
76
|
+
* `secure_image_url` - Set to `true` to use https for the profile picture url. Default is `false`.
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
1. Fork it
|
81
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
82
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
83
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
84
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/example/Gemfile
ADDED
data/example/config.ru
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Sample app for LinkedIn OAuth2 Strategy
|
2
|
+
# Make sure to setup the ENV variables LINKEDIN_KEY and LINKEDIN_SECRET
|
3
|
+
# Run with "bundle exec rackup"
|
4
|
+
|
5
|
+
require 'bundler/setup'
|
6
|
+
require 'sinatra/base'
|
7
|
+
require 'omniauth-linkedin-oauth2'
|
8
|
+
|
9
|
+
class App < Sinatra::Base
|
10
|
+
get '/' do
|
11
|
+
redirect '/auth/linkedin'
|
12
|
+
end
|
13
|
+
|
14
|
+
get '/auth/:provider/callback' do
|
15
|
+
content_type 'application/json'
|
16
|
+
MultiJson.encode(request.env['omniauth.auth'])
|
17
|
+
end
|
18
|
+
|
19
|
+
get '/auth/failure' do
|
20
|
+
content_type 'application/json'
|
21
|
+
MultiJson.encode(request.env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
use Rack::Session::Cookie, :secret => 'change_me'
|
26
|
+
|
27
|
+
use OmniAuth::Builder do
|
28
|
+
provider :linkedin, ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET']
|
29
|
+
end
|
30
|
+
|
31
|
+
run App.new
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class LinkedIn < OmniAuth::Strategies::OAuth2
|
6
|
+
# Give your strategy a name.
|
7
|
+
option :name, 'linkedin'
|
8
|
+
|
9
|
+
# This is where you pass the options you would pass when
|
10
|
+
# initializing your consumer from the OAuth gem.
|
11
|
+
option :client_options, {
|
12
|
+
:site => 'https://api.linkedin.com',
|
13
|
+
:authorize_url => 'https://www.linkedin.com/uas/oauth2/authorization?response_type=code',
|
14
|
+
:token_url => 'https://www.linkedin.com/uas/oauth2/accessToken'
|
15
|
+
}
|
16
|
+
|
17
|
+
option :scope, 'r_basicprofile r_emailaddress'
|
18
|
+
option :fields, ['id', 'email-address', 'first-name', 'last-name', 'headline', 'location', 'industry', 'picture-url', 'public-profile-url']
|
19
|
+
|
20
|
+
# These are called after authentication has succeeded. If
|
21
|
+
# possible, you should try to set the UID without making
|
22
|
+
# additional calls (if the user id is returned with the token
|
23
|
+
# or as a URI parameter). This may not be possible with all
|
24
|
+
# providers.
|
25
|
+
uid { raw_info['id'] }
|
26
|
+
|
27
|
+
info do
|
28
|
+
{
|
29
|
+
:name => user_name,
|
30
|
+
:email => raw_info['emailAddress'],
|
31
|
+
:nickname => user_name,
|
32
|
+
:first_name => raw_info['firstName'],
|
33
|
+
:last_name => raw_info['lastName'],
|
34
|
+
:location => raw_info['location'],
|
35
|
+
:description => raw_info['headline'],
|
36
|
+
:image => raw_info['pictureUrl'],
|
37
|
+
:urls => {
|
38
|
+
'public_profile' => raw_info['publicProfileUrl']
|
39
|
+
}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
extra do
|
44
|
+
{ 'raw_info' => raw_info }
|
45
|
+
end
|
46
|
+
|
47
|
+
def callback_url
|
48
|
+
full_host + script_name + callback_path
|
49
|
+
end
|
50
|
+
|
51
|
+
alias :oauth2_access_token :access_token
|
52
|
+
|
53
|
+
def access_token
|
54
|
+
::OAuth2::AccessToken.new(client, oauth2_access_token.token, {
|
55
|
+
:mode => :query,
|
56
|
+
:param_name => 'oauth2_access_token',
|
57
|
+
:expires_in => oauth2_access_token.expires_in,
|
58
|
+
:expires_at => oauth2_access_token.expires_at
|
59
|
+
})
|
60
|
+
end
|
61
|
+
|
62
|
+
def raw_info
|
63
|
+
@raw_info ||= access_token.get("/v1/people/~:(#{option_fields.join(',')})?format=json").parsed
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def option_fields
|
69
|
+
fields = options.fields
|
70
|
+
fields.map! { |f| f == "picture-url" ? "picture-url;secure=true" : f } if !!options[:secure_image_url]
|
71
|
+
fields
|
72
|
+
end
|
73
|
+
|
74
|
+
def user_name
|
75
|
+
name = "#{raw_info['firstName']} #{raw_info['lastName']}".strip
|
76
|
+
name.empty? ? nil : name
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
OmniAuth.config.add_camelization 'linkedin', 'LinkedIn'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-linkedin-oauth2/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-linkedin-oauth2-cwd"
|
8
|
+
gem.version = OmniAuth::LinkedInOAuth2::VERSION
|
9
|
+
gem.authors = ["Décio Ferreira"]
|
10
|
+
gem.email = ["decio.ferreira@decioferreira.com"]
|
11
|
+
gem.description = %q{A LinkedIn OAuth2 strategy for OmniAuth.}
|
12
|
+
gem.summary = %q{A LinkedIn OAuth2 strategy for OmniAuth.}
|
13
|
+
gem.homepage = "https://github.com/decioferreira/omniauth-linkedin-oauth2"
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_runtime_dependency 'omniauth', '~> 1.0'
|
22
|
+
gem.add_runtime_dependency 'omniauth-oauth2'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
gem.add_development_dependency 'rake'
|
26
|
+
|
27
|
+
gem.add_development_dependency 'rspec', '~> 2.14.1'
|
28
|
+
gem.add_development_dependency 'simplecov'
|
29
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-linkedin-oauth2'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::LinkedIn do
|
5
|
+
subject { OmniAuth::Strategies::LinkedIn.new(nil) }
|
6
|
+
|
7
|
+
it 'should add a camelization for itself' do
|
8
|
+
expect(OmniAuth::Utils.camelize('linkedin')).to eq('LinkedIn')
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#client' do
|
12
|
+
it 'has correct LinkedIn site' do
|
13
|
+
expect(subject.client.site).to eq('https://api.linkedin.com')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has correct authorize url' do
|
17
|
+
expect(subject.client.options[:authorize_url]).to eq('https://www.linkedin.com/uas/oauth2/authorization?response_type=code')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'has correct token url' do
|
21
|
+
expect(subject.client.options[:token_url]).to eq('https://www.linkedin.com/uas/oauth2/accessToken')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#callback_path' do
|
26
|
+
it 'has the correct callback path' do
|
27
|
+
expect(subject.callback_path).to eq('/auth/linkedin/callback')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#uid' do
|
32
|
+
before :each do
|
33
|
+
allow(subject).to receive(:raw_info) { { 'id' => 'uid' } }
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns the id from raw_info' do
|
37
|
+
expect(subject.uid).to eq('uid')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#info' do
|
42
|
+
before :each do
|
43
|
+
allow(subject).to receive(:raw_info) { {} }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'and therefore has all the necessary fields' do
|
47
|
+
it { expect(subject.info).to have_key :name }
|
48
|
+
it { expect(subject.info).to have_key :email }
|
49
|
+
it { expect(subject.info).to have_key :nickname }
|
50
|
+
it { expect(subject.info).to have_key :first_name }
|
51
|
+
it { expect(subject.info).to have_key :last_name }
|
52
|
+
it { expect(subject.info).to have_key :location }
|
53
|
+
it { expect(subject.info).to have_key :description }
|
54
|
+
it { expect(subject.info).to have_key :image }
|
55
|
+
it { expect(subject.info).to have_key :urls }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#extra' do
|
60
|
+
before :each do
|
61
|
+
allow(subject).to receive(:raw_info) { { :foo => 'bar' } }
|
62
|
+
end
|
63
|
+
|
64
|
+
it { expect(subject.extra['raw_info']).to eq({ :foo => 'bar' }) }
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#access_token' do
|
68
|
+
before :each do
|
69
|
+
allow(subject).to receive(:oauth2_access_token) { double('oauth2 access token', :expires_in => 3600, :expires_at => 946688400).as_null_object }
|
70
|
+
end
|
71
|
+
|
72
|
+
it { expect(subject.access_token.expires_in).to eq(3600) }
|
73
|
+
it { expect(subject.access_token.expires_at).to eq(946688400) }
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#raw_info' do
|
77
|
+
before :each do
|
78
|
+
access_token = double('access token')
|
79
|
+
response = double('response', :parsed => { :foo => 'bar' })
|
80
|
+
expect(access_token).to receive(:get).with("/v1/people/~:(baz,qux)?format=json").and_return(response)
|
81
|
+
|
82
|
+
allow(subject).to receive(:option_fields) { ['baz', 'qux'] }
|
83
|
+
allow(subject).to receive(:access_token) { access_token }
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'returns parsed response from access token' do
|
87
|
+
expect(subject.raw_info).to eq({ :foo => 'bar' })
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#authorize_params' do
|
92
|
+
describe 'scope' do
|
93
|
+
before :each do
|
94
|
+
subject.stub(:session => {})
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'sets default scope' do
|
98
|
+
expect(subject.authorize_params['scope']).to eq('r_basicprofile r_emailaddress')
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe '#option_fields' do
|
104
|
+
it 'returns options fields' do
|
105
|
+
subject.stub(:options => double('options', :fields => ['foo', 'bar']).as_null_object)
|
106
|
+
expect(subject.send(:option_fields)).to eq(['foo', 'bar'])
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'http avatar image by default' do
|
110
|
+
subject.stub(:options => double('options', :fields => ['picture-url']))
|
111
|
+
allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(false)
|
112
|
+
expect(subject.send(:option_fields)).to eq(['picture-url'])
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'https avatar image if secure_image_url truthy' do
|
116
|
+
subject.stub(:options => double('options', :fields => ['picture-url']))
|
117
|
+
allow(subject.options).to receive(:[]).with(:secure_image_url).and_return(true)
|
118
|
+
expect(subject.send(:option_fields)).to eq(['picture-url;secure=true'])
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
7
|
+
# loaded once.
|
8
|
+
#
|
9
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
# Run specs in random order to surface order dependencies. If you find an
|
16
|
+
# order dependency and want to debug it, you can fix the order by providing
|
17
|
+
# the seed, which is printed after each run.
|
18
|
+
# --seed 1234
|
19
|
+
config.order = 'random'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-linkedin-oauth2-cwd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Décio Ferreira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-29 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: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.14.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.14.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: A LinkedIn OAuth2 strategy for OmniAuth.
|
98
|
+
email:
|
99
|
+
- decio.ferreira@decioferreira.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".idea/inspectionProfiles/Project_Default.xml"
|
106
|
+
- ".idea/vcs.xml"
|
107
|
+
- ".rspec"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- example/Gemfile
|
114
|
+
- example/config.ru
|
115
|
+
- lib/omniauth-linkedin-oauth2.rb
|
116
|
+
- lib/omniauth-linkedin-oauth2/version.rb
|
117
|
+
- lib/omniauth/strategies/linkedin.rb
|
118
|
+
- omniauth-linkedin-oauth2.gemspec
|
119
|
+
- spec/omniauth/strategies/linkedin_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
homepage: https://github.com/decioferreira/omniauth-linkedin-oauth2
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.5.2
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: A LinkedIn OAuth2 strategy for OmniAuth.
|
145
|
+
test_files:
|
146
|
+
- spec/omniauth/strategies/linkedin_spec.rb
|
147
|
+
- spec/spec_helper.rb
|