Exception` when calling AppApi->create_app: Unauthorized
iamcaleberic opened this issue · comments
Eric Caleb commented
payload = {:scope => 'account'}
jwtHeader = {:kid => ENV['SMOOCH_KEY_ID']}
token = JWT.encode payload, ENV['SMOOCH_SECRET'], 'HS256', jwtHeader
# Setup authorization
SmoochApi.configure do |config|
# Configure API key authorization: jwt
config.api_key['Authorization'] = token
config.api_key_prefix['Authorization'] = 'Bearer'
config.host = 'api.eu-1.smooch.io'
end
api_instance = SmoochApi::AppApi.new
app_create_body = SmoochApi::AppCreate.new # AppCreate | Body for a createApp request.
begin
result = api_instance.create_app(app_create_body)
p result
rescue SmoochApi::ApiError => e
puts "Exception when calling AppApi->create_app: #{e}"
end
Exception` when calling AppApi->create_app: Unauthorized
#10 - Issue references same issue but the workaround does not work
Mike Spensieri commented
Here are a few things to verify to make sure that the authorization you are supplying is correct:
- When using
scope
ofaccount
, make sure that the key ID you supply is an account-level key, i.e. it should begin withact_
- You are setting the host to
api.eu-1.smooch.io
, please make sure that your account has been provisioned with access to the EU platform - If yes for (2), make sure the key ID/secret you are using is one that you got from the EU dashboard and not the public dashboard
Eric Caleb commented
Thanks @mspensieri for the clarifications as to the use of EU platform. I think that should be included in the docs as a note.After changing to the default region everything works.