linkedin_orbit 0.0.2 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c7abc1c20ae9b7ec569164b0da57a7068bf6d66f127c44c26bf174c173da451
4
- data.tar.gz: 3513cc577b03ce3c9001e177f7710056c0dc68514d6ac8ce0d6f6d49322588a9
3
+ metadata.gz: fff300ca5f8ea75c7c1105279561dd768a90838a148eb0ea43b086aecb17e0ed
4
+ data.tar.gz: 6a74e4317caacae6034a574fec736c4ea185559b2b3f6ef3512def8b73fe61c9
5
5
  SHA512:
6
- metadata.gz: 52de2a258c2d8b11b570287e371076cade3aea564fb3147030649fac73dc6c162c7b0f36fe5a6bda3fe62e8eb6ce6e9b323558a0a7240f3a145b87780a7a8e31
7
- data.tar.gz: 737b6bc45c6e848c0886cc51a2245b659f02aee3651a9021b0ca6f1eb8faa64579cabacc90edd594739ac754b91e9e9a4d0dcf817798589de71e4220308fd457
6
+ metadata.gz: 7d1b4860f81499d513e33857556686aea179b47052e0a04fe567b6298d1cda21493bf91c5f9ea4e3d3122b1f9d50149a8477ab6cb2d9d3e02bade259852db6af
7
+ data.tar.gz: 4749a5b174ded3352409a89f46d1dd249c534e9d3d8acf4fc1ac04442d1ea51321e0f74399287ec445a3c1561c0be280d5221605c0f4dd54e1e101f443311fa7
data/.env.sample CHANGED
@@ -1,5 +1,4 @@
1
1
  LINKEDIN_ORGANIZATION=
2
- LINKEDIN_CODE=
3
2
  LINKEDIN_TOKEN=
4
3
  ORBIT_API_KEY=
5
4
  ORBIT_WORKSPACE_ID=
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- linkedin_orbit (0.0.1)
4
+ linkedin_orbit (0.0.2)
5
+ dotenv (~> 2.7)
5
6
  http (~> 4.4)
6
7
  json (~> 2.5)
7
8
  linkedin (~> 1.1)
@@ -20,6 +21,7 @@ GEM
20
21
  diff-lcs (1.4.4)
21
22
  domain_name (0.5.20190701)
22
23
  unf (>= 0.0.5, < 1.0.0)
24
+ dotenv (2.7.6)
23
25
  faraday (1.4.1)
24
26
  faraday-excon (~> 1.1)
25
27
  faraday-net_http (~> 1.0)
data/README.md CHANGED
@@ -20,7 +20,7 @@ The application requires the following environment variables:
20
20
 
21
21
  | Variable | Description | More Info
22
22
  |---|---|--|
23
- | `LINKEDIN_CODE` | LinkedIn Browser Refresh Code | Follow the [First Time Setup guide](docs/FIRST_TIME_INSTRUCTIONS.md) to obtain the code
23
+ | `LINKEDIN_TOKEN` | LinkedIn Token | Follow the [First Time Setup guide](docs/FIRST_TIME_INSTRUCTIONS.md) to obtain the token
24
24
  | `LINKEDIN_ORGANIZATION` | LinkedIn Organization Page ID | Format: `urn:li:organization:#{id}`. ID is the set of numbers in LinkedIn page URL, i.e. `https://www.linkedin.com/company/28866695`, the ID is `28866695`.
25
25
  | `ORBIT_API_KEY` | API key for Orbit | Found in `Account Settings` in your Orbit workspace
26
26
  | `ORBIT_WORKSPACE_ID` | ID for your Orbit workspace | Last part of the Orbit workspace URL, i.e. `https://app.orbit.love/my-workspace`, the ID is `my-workspace`
@@ -43,7 +43,7 @@ You can instantiate a client by either passing in the required credentials durin
43
43
  client = LinkedinOrbit::Client.new(
44
44
  orbit_api_key: YOUR_API_KEY,
45
45
  orbit_workspace_id: YOUR_ORBIT_WORKSPACE_ID,
46
- linkedin_code: YOUR_LINKEDIN_BROWSER_REFRESH_CODE,
46
+ linkedin_token: YOUR_LINKEDIN_TOKEN,
47
47
  linkedin_organization: YOUR_LINKEDIN_ORGANIZATION_ID
48
48
  )
49
49
  ```
@@ -66,7 +66,7 @@ client.comments
66
66
  You can also use this package with the included CLI. To use the CLI pass in the required environment variables on the command line before invoking the CLI:
67
67
 
68
68
  ```bash
69
- $ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... LINKEDIN_CODE=... LINKEDIN_ORGANIZATION=... bundle exec linkedin_orbit --check_comments
69
+ $ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... LINKEDIN_TOKEN=... LINKEDIN_ORGANIZATION=... bundle exec linkedin_orbit --check_comments
70
70
  ```
71
71
  ## GitHub Actions Automation Setup
72
72
 
@@ -1,6 +1,6 @@
1
1
  # Instructions for First Time Set Up
2
2
 
3
- These instructions will walk you through authenticating to LinkedIn, and receiving your LinkedIn code, which is needed to use this integration. You will only need to do this one time.
3
+ These instructions will walk you through authenticating to LinkedIn, and receiving your LinkedIn token, which is needed to use this integration. You will only need to do this once every two months.
4
4
 
5
5
  ## Creating a LinkedIn Developers App
6
6
 
@@ -45,9 +45,9 @@ You will also see on the "Auth" page a section called "OAuth 2.0 Settings". We w
45
45
 
46
46
  After you have finished all of the above steps, you are ready to move on to the last step in this first time setup instructions.
47
47
 
48
- ## LinkedIn Browser Code
48
+ ## LinkedIn Token
49
49
 
50
- LinkedIn uses OAuth 2.0 as its authentication format, and as such, you need to authenticate *one-time* with your browser to obtain a code that will be used for the integration from then on.
50
+ LinkedIn uses OAuth 2.0 as its authentication format, and as such, you need to authenticate *one time every two months* to obtain a token that will be used for the integration from then on.
51
51
 
52
52
  The `linkedin_orbit` integration includes an authentication application to facilitate this process for you. It requires that you have a [Heroku](https://www.heroku.com/) account. It is free to set up a Heroku account, and the one-time authentication app, is fine to run inside the free tier of the platform.
53
53
 
@@ -69,24 +69,26 @@ Copy the URL of the Heroku app in your browser address bar and return to the Lin
69
69
 
70
70
  You will see a link appear called "+ Add redirect URL". Click on that link. In the text box that appears above it enter your Heroku app URL with "/auth/linkedin/callback" appended at the end. For example, if your Heroku URL was "https://example-heroku-app-url.herokuapp.com" then the full address you need to enter would be: "https://example-heroku-app-url.herokuapp.com/auth/linkedin/callback". When you are finished, click on the "Update" button.
71
71
 
72
- Now, return back to your browser window with your Heroku app running. Click on the "LinkedIn" link on the app. Follow the prompts by LinkedIn to authorize your LinkedIn Developer application. When you are finished, you will be redirected back to your Heroku app and you will see a LinkedIn code. This code is very important. The code you see will be the credential used to authenticate to LinkedIn for the duration of your use of the LinkedIn Orbit community integration.
72
+ Now, return back to your browser window with your Heroku app running. Click on the "LinkedIn" link on the app. Follow the prompts by LinkedIn to authorize your LinkedIn Developer application. When you are finished, you will be redirected back to your Heroku app and you will see a LinkedIn token. This token is very important. The token you see will be the credential used to authenticate to LinkedIn.
73
73
 
74
- The last step you need to complete in this first time setup is to add the LinkedIn code you created into the LinkedIn Orbit community integration credentials, either in the context of a standalone app or in the context of running it as a GitHub Action.
74
+ The last step you need to complete in this first time setup is to add the LinkedIn token you created into the LinkedIn Orbit community integration credentials, either in the context of a standalone app or in the context of running it as a GitHub Action.
75
75
 
76
- ## Add the LinkedIn Code to the LinkedIn Orbit Community Integration
76
+ ## Add the LinkedIn Token to the LinkedIn Orbit Community Integration
77
77
  ### Within GitHub Actions
78
78
 
79
79
  *(This step assumes you have a GitHub repository created already to run the LinkedIn Orbit community integration. If you do not, please follow [this guide](https://docs.github.com/en/github/getting-started-with-github/create-a-repo) first.)*
80
80
 
81
- The LinkedIn code you created in the last step needs to be added to the GitHub repository that you are running the LinkedIn Orbit community integration from. To do so, follow the step-by-step guide in the [README](https://github.com/orbit-love/github-actions-templates/blob/main/README.md#adding-your-credentials-to-github) in the GitHub Actions instructions. The name for this secret **must** be: `LINKEDIN_CODE`.
81
+ The LinkedIn token you created in the last step needs to be added to the GitHub repository that you are running the LinkedIn Orbit community integration from. To do so, follow the step-by-step guide in the [README](https://github.com/orbit-love/github-actions-templates/blob/main/README.md#adding-your-credentials-to-github) in the GitHub Actions instructions. The name for this secret **must** be: `LINKEDIN_TOKEN`.
82
82
 
83
83
  ### Within a Standalone App
84
84
 
85
- If you are running the community integration as a standalone app, you can add the LinkedIn code as an environment variable inside the `.env` file in the root directory of the codebase.
85
+ If you are running the community integration as a standalone app, you can add the LinkedIn token as an environment variable inside the `.env` file in the root directory of the codebase.
86
86
 
87
- Open up the `.env` file and add a new line starting with `LINKEDIN_CODE=` and add the LinkedIn Code after the equal sign.
87
+ Open up the `.env` file and add a new line starting with `LINKEDIN_TOKEN=` and add the LinkedIn Code after the equal sign.
88
88
  ## Wrapping Up
89
89
 
90
- You have now successfully finished the first time setup for your LinkedIn Orbit community integration. This is a one-time process, and you can safely delete the Heroku authentication app you deployed.
90
+ You have now successfully finished the setup for your LinkedIn Orbit community integration. This steps needs to occur once every 60 days.
91
+
92
+ In between, you can safely delete the Heroku app you created and recreate a new one when you need to do this again.
91
93
 
92
94
  From within the Heroku dashboard, navigate to the "Settings" for the app and at the very bottom of the page is a button called "Delete app". Once you click on that button, Heroku will confirm you wish to delete the app. Upon confirmation, the app will be deleted and the deployment on the web will be removed.
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "linkedin"
4
+ require "dotenv/load"
5
+ require "net/http"
6
+ require "json"
4
7
 
5
8
  # Create a client to log LinkedIn interactions in your Orbit workspace
6
9
  # Credentials can either be passed in to the instance or be loaded
@@ -15,8 +18,8 @@ require "linkedin"
15
18
  # @option params [String] :orbit_workspace
16
19
  # The workspace ID for the Orbit workspace
17
20
  #
18
- # @option params [String] :linkedin_code
19
- # The browser refresh token obtained after authenticating with LinkedIn
21
+ # @option params [String] :linkedin_token
22
+ # The token obtained after authenticating with LinkedIn
20
23
  # Required if value not provided for LINKEDIN_TOKEN environment variable
21
24
  #
22
25
  # @option params [String] :linkedin_organization
@@ -38,18 +41,12 @@ module LinkedinOrbit
38
41
  def initialize(params = {})
39
42
  @orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
40
43
  @orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
41
- @linkedin_code = params[:linkedin_code] || ENV['LINKEDIN_CODE'] || nil
42
44
  @linkedin_token = token
43
45
  @linkedin_organization = params.fetch(:linkedin_organization, ENV["LINKEDIN_ORGANIZATION"])
44
46
  end
45
47
 
46
48
  def token
47
- @token ||= begin
48
- return ENV["LINKEDIN_TOKEN"] if ENV["LINKEDIN_TOKEN"]
49
-
50
- linkedin = LinkedIn::Client.new(@linkedin_client_id, @linkedin_client_secret)
51
- linkedin.authorize_from_access(ENV["LINKEDIN_CODE"])
52
- end
49
+ @token ||= ENV["LINKEDIN_TOKEN"]
53
50
  end
54
51
 
55
52
  def comments
@@ -41,6 +41,7 @@ module LinkedinOrbit
41
41
  description: construct_description,
42
42
  occurred_at: Time.at(@comment["created"]["time"] / 1000).utc,
43
43
  key: @comment["id"],
44
+ link: "https://www.linkedin.com/feed/update/#{@comment["object"]}",
44
45
  member: {
45
46
  name: name
46
47
  }
@@ -47,7 +47,7 @@ module LinkedinOrbit
47
47
  response = https.request(request)
48
48
 
49
49
  response = JSON.parse(response.body)
50
-
50
+
51
51
  response["elements"].each do |element|
52
52
  posts << {
53
53
  "id" => element["activity"],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LinkedinOrbit
4
- VERSION = "0.0.2"
4
+ VERSION = "0.1.0"
5
5
  end
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "zeitwerk", "~> 2.4"
32
32
  spec.add_dependency "thor", "~> 1.1"
33
33
  spec.add_dependency "linkedin", "~> 1.1"
34
+ spec.add_dependency "dotenv", "~> 2.7"
34
35
  spec.add_development_dependency "rspec", "~> 3.4"
35
36
  spec.add_development_dependency "webmock", "~> 3.12"
36
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linkedin_orbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orbit DevRel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-10 00:00:00.000000000 Z
12
+ date: 2021-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: dotenv
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '2.7'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '2.7'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: rspec
86
100
  requirement: !ruby/object:Gem::Requirement