Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: DeleteUser returns 401 This operation requires 'Authorization' in the HTTP header #49

Closed
1 task done
ihijazi opened this issue Jul 30, 2024 · 1 comment
Closed
1 task done
Labels
bug Something isn't working

Comments

@ihijazi
Copy link

ihijazi commented Jul 30, 2024

What happened?

I'm using the latest .NET SDK, version 2.0.2. The DeleteUser was working fine (and still), but recently it's giving an excpetion.

Notes:

  1. Identity Verification for email + external_id (recommended) is NOT enabled for the app.
  2. The delete user is still partially working. What I mean by that, is that I can I still can find the subscription, but the external_id is deleted from it

This problem just started to happen, nothing changed really from our end.

Can you please advise on what might be wrong here?

Steps to reproduce?

Code used:
 
     var appConfig = new Configuration();
        appConfig.BasePath = oneSignalApiUrl;
        appConfig.AccessToken = oneSignalAccessToken;
        

        var apiInstance = new DefaultApi(appConfig);

        try
        {
            apiInstance.DeleteUser(oneSignalAppId, "external_id", payloadData.Username);
            return true;
        }


### What did you expect to happen?

No exception
Subscription to be fully deleted, not just the external_id within it.

### Relevant log output

```Shell
Error calling DeleteUser: 
{
    "errors": [
        {
            "code": "auth-1",
            "title": "This operation requires 'Authorization' in the HTTP header"
        }
    ]
}
   at OneSignalApi.Api.DefaultApi.DeleteUserWithHttpInfo(String appId, String aliasLabel, String aliasId, Int32 operationIndex)
   at OneSignalApi.Api.DefaultApi.DeleteUser(String appId, String aliasLabel, String aliasId, Int32 operationIndex)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ihijazi ihijazi added the bug Something isn't working label Jul 30, 2024
@ihijazi
Copy link
Author

ihijazi commented Jul 30, 2024

Fixed it by adding headers manually for authorization.

Weird thing it used to work fine with just setting AccessToken.

Also documentation doesn't mention this.

Here is what I did:

var appConfig = new Configuration();
appConfig.BasePath = oneSignalApiUrl;
//appConfig.AccessToken = oneSignalAccessToken;
appConfig.DefaultHeaders.Add("Authorization", "Basic " + oneSignalAccessToken);

Closing this.

@ihijazi ihijazi closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant