diff --git a/Gemfile b/Gemfile
index 8ca232fc1e624bb846c52eea3a4ff60c74e4f1e7..368b186f2c8d5043e5d1da871aad3c4b7da6c6bc 100644
--- a/Gemfile
+++ b/Gemfile
@@ -466,7 +466,7 @@ gem 'benchmark-memory', '~> 0.1', require: false
 gem 'activerecord-explain-analyze', '~> 0.1', require: false
 
 # OAuth
-gem 'oauth2', '~> 1.4'
+gem 'oauth2', '~> 2.0'
 
 # Health check
 gem 'health_check', '~> 3.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index 2c6a35fe072d5154011282de227e2e9704e54171..809015f3ba5384de09fc68ba26d760b3146664b8 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -815,12 +815,13 @@ GEM
       shellany (~> 0.0)
     numerizer (0.2.0)
     oauth (0.5.6)
-    oauth2 (1.4.7)
-      faraday (>= 0.8, < 2.0)
+    oauth2 (2.0.2)
+      faraday (>= 0.17.3, < 3.0)
       jwt (>= 1.0, < 3.0)
-      multi_json (~> 1.3)
       multi_xml (~> 0.5)
       rack (>= 1.2, < 3)
+      rash_alt (>= 0.4, < 1)
+      version_gem (~> 1.0)
     octokit (4.20.0)
       faraday (>= 0.9)
       sawyer (~> 0.8.0, >= 0.5.3)
@@ -1042,6 +1043,8 @@ GEM
     rainbow (3.1.1)
     rake (13.0.6)
     randexp (0.1.7)
+    rash_alt (0.4.12)
+      hashie (>= 3.4)
     rb-fsevent (0.10.4)
     rb-inotify (0.10.1)
       ffi (~> 1.0)
@@ -1400,6 +1403,7 @@ GEM
     validates_hostname (1.0.11)
       activerecord (>= 3.0)
       activesupport (>= 3.0)
+    version_gem (1.0.0)
     version_sorter (2.2.4)
     view_component (2.50.0)
       activesupport (>= 5.0.0, < 8.0)
@@ -1604,7 +1608,7 @@ DEPENDENCIES
   net-ldap (~> 0.16.3)
   net-ntp
   nokogiri (~> 1.13.6)
-  oauth2 (~> 1.4)
+  oauth2 (~> 2.0)
   octokit (~> 4.15)
   ohai (~> 16.10)
   oj (~> 3.10.6)
diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb
index 8f11ab86efa8d6876c4b3f73f7d901489664464f..af220e2d5159a7ff191d3021dc3ed498cdde2e82 100644
--- a/spec/controllers/import/bitbucket_controller_spec.rb
+++ b/spec/controllers/import/bitbucket_controller_spec.rb
@@ -65,7 +65,7 @@ def assign_session_tokens
           .with(hash_including(
                   'grant_type' => 'authorization_code',
                   'code' => code,
-                  redirect_uri: users_import_bitbucket_callback_url),
+                  'redirect_uri' => users_import_bitbucket_callback_url),
                 {})
           .and_return(access_token)
         stub_omniauth_provider('bitbucket')
diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb
index eb4c404e45476bff192ef92dc64b26828b7f363e..984c690add6c03f7de34f577afbbfb0b318ed921 100644
--- a/spec/lib/gitlab/gitlab_import/importer_spec.rb
+++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb
@@ -21,8 +21,8 @@
             'name' => 'John Doe'
           }
         }
-      ])
-      stub_request('issues/3/notes', [])
+      ].to_json)
+      stub_request('issues/3/notes', [].to_json)
     end
 
     it 'persists issues' do