omniauth-instagram_basic 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 76340ef7fad12138924b33eb436fe8f6e1a1d978925c61dc8d7bf5ea55e990d0
4
+ data.tar.gz: 16fe1e9712e7b813cf5e922caa49038b398d2ac9ffe43b7d3523ce252fbf68a3
5
+ SHA512:
6
+ metadata.gz: 5b619ced8cca20557ed9ad31c9068b98d42b6a116294fe892dbd7c16597b64c3270a393fa62f88b8714d15928ebc80f29c462af362abe4514e309b59d532c22c
7
+ data.tar.gz: 385e7bfa03bf8165930367aa5c9bff479c93c1459fe4ca6f91e7e53fe4dd3e71a933db3d2dd487b9a64c21fc775e8bc2e3a628878b5e8a1111c7d4250807f951
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2022-09-07
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at barker.cameron@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in omniauth-instagram_basic.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 ParkerBarker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # OmniAuth::InstagramBasic
2
+
3
+ OmniAuth staregy for [Instagram Basic Display Api](https://developers.facebook.com/docs/instagram-basic-display-api). For issues please ping me on Twitter @cameronbarker.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-instagram_basic'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-instagram_basic
20
+
21
+ ## Usage
22
+
23
+ ```
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :instagram_display, ENV['INSTAGRAM_CLIENT_ID'], ENV['INSTAGRAM_CLIENT_SECRET'], scope:'user_profile,user_media'
26
+ end
27
+ ```
28
+
29
+ ```
30
+ {
31
+ "provider"=>"instagram_basic",
32
+ "uid"=>17841400623220074,
33
+ "info"=> {
34
+ "id"=>"5375921395840366",
35
+ "account_type"=>"PERSONAL",
36
+ "media_count"=>994,
37
+ "username"=>"parkerbarkers"
38
+ },
39
+ "credentials"=> {
40
+ "token"=> "IGQVJYZA29lbGVTMjdvMTZAnS09jYnhWN0F1NkdVV2x5aGgtU2U1SUFLMHBpWVpkd2Q4eDlORGx1bnpjbUhGaklkX293RDEtY3IydmI0c0pUQU9vT2FMMWkzeEV5cURTdmxZAV0d5LUlp",
41
+ "expires"=> true,
42
+ "short_lived_token"=> "IGQVJVQXBZAU1ltY0tEckUxSWlURjJzc0NGOFFKejBsaHZA3YmpuSWVBNTNMSUtxYTJIR0NSUFEyaTlQRHJ3SUJqQ2ZAjRHlFQURCMEs3UWFrRkFOWnRkd0N3bmNRQWFVSllTZAExSM2poekFZALVVtRVc4Q3JnNHJRMnpHMWZAs",
43
+ "expires_at"=> 5181752
44
+ },
45
+ "extra"=> {
46
+ "raw_info" =>
47
+ { "id"=> "5175921395840366",
48
+ "account_type"=> "PERSONAL",
49
+ "media_count"=> 994,
50
+ "username"=> "parkerbarkers"}
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ ## Development
57
+
58
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
59
+
60
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
61
+
62
+ ## Contributing
63
+
64
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cameronbarker/omniauth-instagram_basic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/cameronbarker/omniauth-instagram_basic/blob/main/CODE_OF_CONDUCT.md).
65
+
66
+ ## License
67
+
68
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
69
+
70
+ ## Code of Conduct
71
+
72
+ Everyone interacting in the Omniauth::InstagramBasic project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cameronbarker/omniauth-instagram_basic/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "omniauth/instagram_basic"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omniauth
4
+ module InstagramBasic
5
+ VERSION = "1.0.0"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "instagram_basic/version"
4
+ require_relative "strategies/instagram_basic"
5
+
6
+ module Omniauth
7
+ module InstagramBasic
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
11
+ end
@@ -0,0 +1,63 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class InstagramBasic < OmniAuth::Strategies::OAuth2
6
+ SITE_URL = 'https://api.instagram.com'.freeze
7
+ TOKEN_PATH = 'oauth/access_token'.freeze
8
+ TOKEN_OPTIONS = ["client_id", "client_secret"].freeze
9
+
10
+ option :client_options, site: SITE_URL, token_url: TOKEN_PATH
11
+ option :token_options, TOKEN_OPTIONS
12
+ option :name, 'instagram_basic'
13
+
14
+ uid { access_token.response.parsed["user_id"] }
15
+ extra { { raw_info: raw_info } }
16
+ info { info_generator }
17
+ credentials { credentials_generator }
18
+
19
+ def callback_url
20
+ options[:redirect_uri] || (full_host + script_name + callback_path)
21
+ end
22
+
23
+ # Instagram provides a short lived token initial with the option to request a long lived token
24
+ # https://developers.facebook.com/docs/instagram-basic-display-api/guides/long-lived-access-tokens
25
+ def raw_token_info
26
+ url = "https://graph.instagram.com/access_token? \
27
+ grant_type=ig_exchange_token \
28
+ &client_secret=#{token_params["client_secret"]} \
29
+ &access_token=#{access_token.token}"
30
+
31
+ @raw_token_info ||= access_token.get(url).parsed || {}
32
+ end
33
+
34
+ # Get user info
35
+ # https://developers.facebook.com/docs/instagram-basic-display-api/reference/me
36
+ def raw_info
37
+ url = "https://graph.instagram.com/me? \
38
+ fields=id,account_type,media_count,username \
39
+ &access_token=#{access_token.token}"
40
+
41
+ @raw_info ||= access_token.get(url).parsed || {}
42
+ end
43
+
44
+ def info_generator
45
+ {
46
+ id: raw_info["id"],
47
+ account_type: raw_info["account_type"],
48
+ media_count: raw_info["media_count"],
49
+ username: raw_info["username"]
50
+ }
51
+ end
52
+
53
+ def credentials_generator
54
+ {
55
+ "token" => raw_token_info["access_token"],
56
+ "short_lived_token" => access_token.token,
57
+ "expires" => true,
58
+ "expires_at" => raw_token_info["expires_in"]
59
+ }
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,6 @@
1
+ module Omniauth
2
+ module InstagramBasic
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-instagram_basic
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Cameron Barker
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-08 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: 'Instagram Basic Display API OAuth2 strategy for OmniAuth. See: https://developers.facebook.com/docs/instagram-basic-display-api'
42
+ email:
43
+ - barker.cameron@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - CODE_OF_CONDUCT.md
52
+ - Gemfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/omniauth/instagram_basic.rb
59
+ - lib/omniauth/instagram_basic/version.rb
60
+ - lib/omniauth/strategies/instagram_basic.rb
61
+ - sig/omniauth/instagram_basic.rbs
62
+ homepage: https://www.parkerbarker.com
63
+ licenses:
64
+ - MIT
65
+ metadata:
66
+ homepage_uri: https://www.parkerbarker.com
67
+ source_code_uri: https://github.com/parkerbarker/omniauth-instagram_basic
68
+ changelog_uri: https://github.com/parkerbarker/omniauth-instagram_basic
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 2.6.0
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubygems_version: 3.2.33
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Instagram Basic Display API OAuth2 strategy for OmniAuth
88
+ test_files: []