omniauth-soundcloud2 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: 2f98fb76717174c57aba29869a0c66343e926de7f068afb622dbe8983d9a5233
4
+ data.tar.gz: '0991c9b13d02d8ec9f5374e6f131b6c4b22ccd546c390c91cad8c42c4b94e441'
5
+ SHA512:
6
+ metadata.gz: b86712bb55610ab72d4be226399e23bc58013956a4925f02a69120bd234b13732e50bfddc20bb77a9e8c2721be4bfe12cf553bb004070be935ffa25d21cac836
7
+ data.tar.gz: 8849688b39e1a24889244bfa95d1ba538171600599e9675e765ccfdc49f5f1692a665075348e368be366799ea135797cb7216501891a8528a286dc6a97060684
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Claudio Poli
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # OmniAuth SoundCloud2 Strategy
2
+
3
+ [![Test](https://github.com/icoretech/omniauth-soundcloud2/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/icoretech/omniauth-soundcloud2/actions/workflows/test.yml?query=branch%3Amain)
4
+ [![Gem Version](https://img.shields.io/gem/v/omniauth-soundcloud2.svg)](https://rubygems.org/gems/omniauth-soundcloud2)
5
+
6
+ `omniauth-soundcloud2` provides a SoundCloud OAuth2 strategy for OmniAuth.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'omniauth-soundcloud2'
14
+ ```
15
+
16
+ Then run:
17
+
18
+ ```bash
19
+ bundle install
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ Configure OmniAuth in your Rack/Rails app:
25
+
26
+ ```ruby
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :soundcloud,
29
+ ENV.fetch('SOUNDCLOUD_CLIENT_ID'),
30
+ ENV.fetch('SOUNDCLOUD_CLIENT_SECRET')
31
+ end
32
+ ```
33
+
34
+ You can optionally pass `scope` and `display` in the request query.
35
+
36
+ ## Auth Hash
37
+
38
+ Example payload from `request.env['omniauth.auth']` (realistic shape, anonymized):
39
+
40
+ ```json
41
+ {
42
+ "uid": "14743149",
43
+ "info": {
44
+ "name": "Sample Person",
45
+ "nickname": "Sample Person",
46
+ "image": "https://i1.sndcdn.com/avatars-000000000000-example-large.jpg",
47
+ "urls": {
48
+ "SoundCloud": "https://soundcloud.com/sample-person?utm_source=id_12345"
49
+ }
50
+ },
51
+ "credentials": {
52
+ "token": "eyJ...redacted...xYxvrQ",
53
+ "refresh_token": "A1B2C3D4E5F6",
54
+ "expires_at": 1772691847,
55
+ "expires": true
56
+ },
57
+ "extra": {
58
+ "raw_info": {
59
+ "avatar_url": "https://i1.sndcdn.com/avatars-000000000000-example-large.jpg",
60
+ "id": 14743149,
61
+ "urn": "soundcloud:users:14743149",
62
+ "kind": "user",
63
+ "permalink_url": "https://soundcloud.com/sample-person?utm_source=id_12345",
64
+ "uri": "https://api.soundcloud.com/users/soundcloud:users:14743149",
65
+ "username": "Sample Person",
66
+ "permalink": "sample-person",
67
+ "created_at": "2012/04/05 16:38:45 +0000",
68
+ "last_modified": "2016/12/07 19:35:32 +0000",
69
+ "first_name": "Sample",
70
+ "last_name": "Person",
71
+ "full_name": "Sample Person",
72
+ "city": null,
73
+ "description": null,
74
+ "country": null,
75
+ "track_count": 1,
76
+ "public_favorites_count": 0,
77
+ "reposts_count": 0,
78
+ "followers_count": 8,
79
+ "followings_count": 1,
80
+ "plan": "Free",
81
+ "website_title": null,
82
+ "website": null,
83
+ "comments_count": 0,
84
+ "online": false,
85
+ "likes_count": 0,
86
+ "playlist_count": 0,
87
+ "subscriptions": [
88
+ {
89
+ "product": {
90
+ "id": "free",
91
+ "name": "Free"
92
+ }
93
+ }
94
+ ],
95
+ "quota": {
96
+ "unlimited_upload_quota": false,
97
+ "upload_seconds_used": 336,
98
+ "upload_seconds_left": 10464
99
+ },
100
+ "private_tracks_count": 5,
101
+ "private_playlists_count": 1,
102
+ "primary_email_confirmed": true,
103
+ "locale": "",
104
+ "upload_seconds_left": 10464
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ## Development
111
+
112
+ ```bash
113
+ bundle install
114
+ bundle exec rake
115
+ ```
116
+
117
+ Run Rails integration tests with an explicit Rails version:
118
+
119
+ ```bash
120
+ RAILS_VERSION='~> 8.1.0' bundle install
121
+ RAILS_VERSION='~> 8.1.0' bundle exec rake test_rails_integration
122
+ ```
123
+
124
+ ## Compatibility
125
+
126
+ - Ruby: `>= 3.2` (tested on `3.2`, `3.3`, `3.4`, `4.0`)
127
+ - `omniauth-oauth2`: `>= 1.8`, `< 1.9`
128
+ - Rails integration lanes: `~> 7.1.0`, `~> 7.2.0`, `~> 8.0.0`, `~> 8.1.0`
129
+
130
+ ## Release
131
+
132
+ Tag releases as `vX.Y.Z`; GitHub Actions publishes the gem to RubyGems.
133
+
134
+ ## License
135
+
136
+ MIT
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/soundcloud2/version'
4
+
5
+ module OmniAuth
6
+ module SoundCloud
7
+ VERSION = OmniAuth::Soundcloud2::VERSION unless const_defined?(:VERSION)
8
+ end
9
+
10
+ module Soundcloud
11
+ VERSION = OmniAuth::Soundcloud2::VERSION unless const_defined?(:VERSION)
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/soundcloud/version'
4
+ require 'omniauth/strategies/soundcloud'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Soundcloud2
5
+ VERSION = '1.0.0'
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/soundcloud2/version'
4
+ require 'omniauth/strategies/soundcloud'
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth-oauth2'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ # OmniAuth strategy for SoundCloud OAuth2.
8
+ class SoundCloud < OmniAuth::Strategies::OAuth2
9
+ DEFAULT_SCOPE = 'non-expiring'
10
+
11
+ option :name, 'soundcloud'
12
+
13
+ option :client_options,
14
+ site: 'https://api.soundcloud.com',
15
+ authorize_url: 'https://secure.soundcloud.com/authorize',
16
+ token_url: 'https://secure.soundcloud.com/oauth/token',
17
+ auth_scheme: :request_body,
18
+ connection_opts: {
19
+ headers: {
20
+ user_agent: 'icoretech-omniauth-soundcloud2 gem',
21
+ accept: 'application/json',
22
+ content_type: 'application/json'
23
+ }
24
+ }
25
+
26
+ option :authorize_options, %i[scope state display]
27
+ option :scope, DEFAULT_SCOPE
28
+
29
+ uid { raw_info['id'].to_s }
30
+
31
+ info do
32
+ {
33
+ name: raw_info['full_name'] || raw_info['username'],
34
+ nickname: raw_info['username'],
35
+ image: raw_info['avatar_url'],
36
+ description: blank_to_nil(raw_info['description']),
37
+ location: raw_info['city'],
38
+ urls: urls
39
+ }.compact
40
+ end
41
+
42
+ extra do
43
+ {
44
+ 'raw_info' => raw_info
45
+ }
46
+ end
47
+
48
+ def raw_info
49
+ @raw_info ||= access_token.get('me').parsed
50
+ end
51
+
52
+ # Ensure token exchange uses a stable callback URI that matches provider config.
53
+ def callback_url
54
+ options[:callback_url] || super
55
+ end
56
+
57
+ # Prevent authorization response params from being appended to redirect_uri.
58
+ def query_string
59
+ return '' if request.params['code']
60
+
61
+ super
62
+ end
63
+
64
+ private
65
+
66
+ def urls
67
+ data = {
68
+ SoundCloud: raw_info['permalink_url'],
69
+ Website: raw_info['website']
70
+ }.compact
71
+ data.empty? ? nil : data
72
+ end
73
+
74
+ def blank_to_nil(value)
75
+ return nil if value.respond_to?(:empty?) && value.empty?
76
+
77
+ value
78
+ end
79
+ end
80
+
81
+ Soundcloud = SoundCloud
82
+ SoundCloud2 = SoundCloud
83
+ end
84
+ end
85
+
86
+ OmniAuth.config.add_camelization 'soundcloud', 'SoundCloud'
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/soundcloud/version'
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/soundcloud'
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/soundcloud2/version'
4
+
5
+ # Backward compatibility for historical constant usage.
6
+ module Omniauth
7
+ module Soundcloud2
8
+ VERSION = OmniAuth::Soundcloud2::VERSION unless const_defined?(:VERSION)
9
+ end
10
+
11
+ module SoundCloud
12
+ VERSION = OmniAuth::Soundcloud2::VERSION unless const_defined?(:VERSION)
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/soundcloud2'
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'omniauth/soundcloud2/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'omniauth-soundcloud2'
9
+ spec.version = OmniAuth::Soundcloud2::VERSION
10
+ spec.authors = ['Claudio Poli']
11
+ spec.email = ['masterkain@gmail.com']
12
+
13
+ spec.summary = 'OmniAuth strategy for SoundCloud OAuth2 authentication.'
14
+ spec.description =
15
+ 'OAuth2 strategy for OmniAuth that authenticates users with SoundCloud and exposes account metadata.'
16
+ spec.homepage = 'https://github.com/icoretech/omniauth-soundcloud2'
17
+ spec.license = 'MIT'
18
+ spec.required_ruby_version = '>= 3.2'
19
+
20
+ spec.metadata['source_code_uri'] = 'https://github.com/icoretech/omniauth-soundcloud2'
21
+ spec.metadata['bug_tracker_uri'] = 'https://github.com/icoretech/omniauth-soundcloud2/issues'
22
+ spec.metadata['changelog_uri'] = 'https://github.com/icoretech/omniauth-soundcloud2/releases'
23
+ spec.metadata['rubygems_mfa_required'] = 'true'
24
+
25
+ spec.files = Dir[
26
+ 'lib/**/*.rb',
27
+ 'README*',
28
+ 'LICENSE*',
29
+ '*.gemspec'
30
+ ]
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_dependency 'cgi', '>= 0.3.6'
34
+ spec.add_dependency 'omniauth-oauth2', '>= 1.8', '< 1.9'
35
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-soundcloud2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Claudio Poli
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: cgi
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.3.6
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 0.3.6
26
+ - !ruby/object:Gem::Dependency
27
+ name: omniauth-oauth2
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '1.8'
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.9'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '1.8'
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: '1.9'
46
+ description: OAuth2 strategy for OmniAuth that authenticates users with SoundCloud
47
+ and exposes account metadata.
48
+ email:
49
+ - masterkain@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - LICENSE.txt
55
+ - README.md
56
+ - lib/omniauth-soundcloud.rb
57
+ - lib/omniauth-soundcloud/version.rb
58
+ - lib/omniauth-soundcloud2.rb
59
+ - lib/omniauth-soundcloud2/version.rb
60
+ - lib/omniauth/soundcloud.rb
61
+ - lib/omniauth/soundcloud/version.rb
62
+ - lib/omniauth/soundcloud2.rb
63
+ - lib/omniauth/soundcloud2/version.rb
64
+ - lib/omniauth/strategies/soundcloud.rb
65
+ - omniauth-soundcloud2.gemspec
66
+ homepage: https://github.com/icoretech/omniauth-soundcloud2
67
+ licenses:
68
+ - MIT
69
+ metadata:
70
+ source_code_uri: https://github.com/icoretech/omniauth-soundcloud2
71
+ bug_tracker_uri: https://github.com/icoretech/omniauth-soundcloud2/issues
72
+ changelog_uri: https://github.com/icoretech/omniauth-soundcloud2/releases
73
+ rubygems_mfa_required: 'true'
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: '3.2'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.6.9
89
+ specification_version: 4
90
+ summary: OmniAuth strategy for SoundCloud OAuth2 authentication.
91
+ test_files: []