Skip to content

SMSNoc Provider returns 401 Unauthorized #100

Description

@aashiqhasnat

GitHub Issue: SMSNoc Provider returns 401 Unauthorized (Uses Outdated v3 API Endpoint)

Title

Bug: SMSNoc Provider returns 401 Unauthorized (Uses Outdated v3 API Endpoint)


Description

The current implementation of the SMSNoc provider class (Xenon\LaravelBDSms\Provider\SMSNoc) uses an outdated and deprecated API endpoint:

  • Current package endpoint: https://app.smsnoc.com/api/v3/sms/send
  • Official working endpoint: https://smsnoc.com/api/v1/send-sms

Making requests to the outdated /api/v3 URL results in a 401 Unauthorized HTML response from SMS NOC, even with fully valid Bearer Tokens. Additionally, the official SMS NOC documentation specifies sending requests to the V1 endpoint in JSON format.


Steps to Reproduce

  1. Configure SMS settings to use the SMSNoc provider with a valid sender_id and bearer_token.
  2. Trigger an SMS send event.
  3. The client receives a 401 Unauthorized client exception.

Root Cause & Code Details

1. Outdated API Endpoint in SMSNoc.php

In vendor/xenon/laravelbdsms/src/Provider/SMSNoc.php:

private string $apiEndpoint = 'https://app.smsnoc.com/api/v3/sms/send';

According to official SMS NOC API Docs, the standard endpoint is:

private string $apiEndpoint = 'https://smsnoc.com/api/v1/send-sms';

2. Duplicate Request Parameters in Request.php

Additionally, when sending JSON POST requests, Guzzle's optionsPostRequest in Xenon\LaravelBDSms\Request appends parameters in the URL and the JSON body simultaneously since it does not unset($options['query']) when isContentTypeJson() is true:

if ($this->isContentTypeJson()) {
    $options[RequestOptions::JSON] = $this->query;
}

This causes Guzzle to query parameterize the payload to the URL like POST https://app.smsnoc.com/api/v3/sms/send?recipient=...&message=... while simultaneously sending a JSON body.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions