Bugfix: Improve error messaging in Twitter app configuration flow
This commit is contained in:
parent
bdec29179d
commit
64e08dfc48
2 changed files with 15 additions and 8 deletions
|
@ -29,11 +29,14 @@ class ExternalCredential::Twitter
|
|||
begin
|
||||
request_token = consumer.get_request_token(oauth_callback: ExternalCredential.callback_url('twitter'))
|
||||
rescue => e
|
||||
if e.message == '403 Forbidden'
|
||||
raise "#{e.message}, maybe credentials wrong or callback_url for application wrong configured."
|
||||
case e.message
|
||||
when '401 Authorization Required'
|
||||
raise "#{e.message} (Invalid credentials may be to blame.)"
|
||||
when '403 Forbidden'
|
||||
raise "#{e.message} (Your app's callback URL configuration on developer.twitter.com may be to blame.)"
|
||||
else
|
||||
raise
|
||||
end
|
||||
|
||||
raise e
|
||||
end
|
||||
|
||||
{
|
||||
|
|
|
@ -224,7 +224,9 @@ RSpec.describe 'External Credentials', type: :request do
|
|||
|
||||
include_examples 'for failure cases' do
|
||||
let(:status) { :ok }
|
||||
let(:error_message) { '401 Authorization Required' }
|
||||
let(:error_message) { <<~ERR.chomp }
|
||||
401 Authorization Required (Invalid credentials may be to blame.)
|
||||
ERR
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -234,7 +236,7 @@ RSpec.describe 'External Credentials', type: :request do
|
|||
include_examples 'for failure cases' do
|
||||
let(:status) { :ok }
|
||||
let(:error_message) { <<~ERR.chomp }
|
||||
403 Forbidden, maybe credentials wrong or callback_url for application wrong configured.
|
||||
403 Forbidden (Your app's callback URL configuration on developer.twitter.com may be to blame.)
|
||||
ERR
|
||||
end
|
||||
end
|
||||
|
@ -343,7 +345,9 @@ RSpec.describe 'External Credentials', type: :request do
|
|||
|
||||
include_examples 'for failure cases' do
|
||||
let(:status) { :internal_server_error }
|
||||
let(:error_message) { '401 Authorization Required' }
|
||||
let(:error_message) { <<~ERR.chomp }
|
||||
401 Authorization Required (Invalid credentials may be to blame.)
|
||||
ERR
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -353,7 +357,7 @@ RSpec.describe 'External Credentials', type: :request do
|
|||
include_examples 'for failure cases' do
|
||||
let(:status) { :internal_server_error }
|
||||
let(:error_message) { <<~ERR.chomp }
|
||||
403 Forbidden, maybe credentials wrong or callback_url for application wrong configured.
|
||||
403 Forbidden (Your app's callback URL configuration on developer.twitter.com may be to blame.)
|
||||
ERR
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue