OneSignal / onesignal-python-api

Other
12 stars 6 forks source link

[Bug]: create_app returns 500 Internal Server Error #16

Open makmac213 opened 1 year ago

makmac213 commented 1 year ago

What happened?

We are building a multi-tenant application and we want to create a Onesignal app via api. The create_app function returns 500 error status.

image

` def create_onesignal_app(tenant): configuration = onesignal.Configuration( user_key=settings.ONE_SIGNAL_USER_AUTH_KEY ) with onesignal.ApiClient(configuration) as api_client: hostname = get_hostname(tenant) default_url = f"https://{hostname}"

    api_instance = default_api.DefaultApi(api_client)
    app = App(
        name=tenant.subdomain,
        chrome_web_origin=default_url,
        chrome_web_default_notification_icon='./static/notification/odzi-onesignal.png',
        site_name=tenant.subdomain,
        apns_p8=''
    )
    try:
        api_response = api_instance.create_app(app)
    except onesignal.ApiException as e:
        # notify_exception_to_admin('@create_onesignal_app')
        print(e)

`

Steps to reproduce?

1. Try to create an app using create_app

What did you expect to happen?

I expected the API to create an app or provide error messages so that I can fix what the errors that I may have caused.

Relevant log output

Status Code: 500
Reason: Internal Server Error
HTTP response headers: HTTPHeaderDict({'Date': 'Mon, 27 Mar 2023 02:15:57 GMT', 'Content-Type': 'application/json; charset=UTF-8', 'Content-Length': '46', 'Connection': 'keep-alive', 'vary': 'Origin', 'x-request-id': 'f5aae66b-5f6d-4fd3-8c43-d83a1ad72793', 'x-runtime': '0.566735', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400', 'CF-Cache-Status': 'DYNAMIC', 'Set-Cookie': '__cf_bm=SlqzXoBa8mMnIbGjHADK41NqkpN4E0tIxCY1_C2JaYo-1679883357-0-AZ0xw4NBT3NNt0X9Zl7nb6ODh3XqQpdw2+Eyf7z1Q58kNeHIdZPSaDd1tXQjAAMwLBQBtCDmVayLftoU63GfoAM=; path=/; expires=Mon, 27-Mar-23 02:45:57 GMT; domain=.onesignal.com; HttpOnly; Secure; SameSite=None', 'Strict-Transport-Security': 'max-age=15552000; includeSubDomains', 'Server': 'cloudflare', 'CF-RAY': '7ae420e3aeac4553-CGY'})
HTTP response body: {"status":500,"error":"Internal Server Error"}

Code of Conduct

makmac213 commented 1 year ago

Just an update. When I tried again this function it does create an app, I confirmed on the dashboard it does. The only issue at the moment is the response that I got which is still the 500 internal server error message.

emawby commented 1 year ago

Thank you for reporting we will investigate

luis-kaufmann-silva commented 1 year ago

If it helps, let me share few other details about same issue here: Sounds like the problem is related with apns_p8. If you try create the app without it works fine, then if you try to update the apns_p8 to something invalid the system raise 500 error. I took few tries to realize that my apns_p8 was invalid and not base64 encoded.

emawby commented 1 year ago

Oh very interesting does a valid p8 work as expected?