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
|
begin
|
||||||
request_token = consumer.get_request_token(oauth_callback: ExternalCredential.callback_url('twitter'))
|
request_token = consumer.get_request_token(oauth_callback: ExternalCredential.callback_url('twitter'))
|
||||||
rescue => e
|
rescue => e
|
||||||
if e.message == '403 Forbidden'
|
case e.message
|
||||||
raise "#{e.message}, maybe credentials wrong or callback_url for application wrong configured."
|
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
|
end
|
||||||
|
|
||||||
raise e
|
|
||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -224,7 +224,9 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
|
|
||||||
include_examples 'for failure cases' do
|
include_examples 'for failure cases' do
|
||||||
let(:status) { :ok }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -234,7 +236,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
include_examples 'for failure cases' do
|
include_examples 'for failure cases' do
|
||||||
let(:status) { :ok }
|
let(:status) { :ok }
|
||||||
let(:error_message) { <<~ERR.chomp }
|
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
|
ERR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -343,7 +345,9 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
|
|
||||||
include_examples 'for failure cases' do
|
include_examples 'for failure cases' do
|
||||||
let(:status) { :internal_server_error }
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -353,7 +357,7 @@ RSpec.describe 'External Credentials', type: :request do
|
||||||
include_examples 'for failure cases' do
|
include_examples 'for failure cases' do
|
||||||
let(:status) { :internal_server_error }
|
let(:status) { :internal_server_error }
|
||||||
let(:error_message) { <<~ERR.chomp }
|
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
|
ERR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue