PHPackages                             larva/laravel-passport-sms - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. larva/laravel-passport-sms

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

larva/laravel-passport-sms
==========================

This is a Laravel passport grant for the SMS.

1.0.6(4y ago)22.2kMITPHP

Since Mar 12Pushed 4y agoCompare

[ Source](https://github.com/larvatecn/laravel-passport-sms)[ Packagist](https://packagist.org/packages/larva/laravel-passport-sms)[ RSS](/packages/larva-laravel-passport-sms/feed)WikiDiscussions master Synced yesterday

READMEChangelog (7)Dependencies (2)Versions (8)Used By (0)

SMS Grant for Laravel Passport
==============================

[](#sms-grant-for-laravel-passport)

This package is useful to combine your Oauth2 Server with SMS Login.

Installation
------------

[](#installation)

This package can be installed through Composer.

```
composer require larva/laravel-passport-sms

```

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in config/app.php file:

```
// config/app.php
'providers' => [
    ...
    "Larva\Passport\Sms\SmsLoginGrantProvider::class,
    ...
];
```

How to use
----------

[](#how-to-use)

- Make a POST request to , just like you would a Password or Refresh grant.
- The POST body should contain grant\_type = sms.
- The request will get routed to your User::findAndValidateForPassportSms() function, where you will determine if access should be granted or not.
- An access\_token and refresh\_token will be returned if successful.

Request
-------

[](#request)

```
$response = $http->post('http://your-app.com/oauth/token', [
    'form_params' => [
        'grant_type' => 'sms',
        'client_id' => 'client-id',
        'client_secret' => 'client-secret',
        'phone' => '13800138000',
        'verifyCode' => 'SMS verifyCode',
    ],
]);

## Example

Here is what a `User::findAndValidateForPassportSms()` method might look like...

```php
/**
 * Verify and retrieve user by custom token request.
 *
 * @param \Illuminate\Http\Request $request
 *
 * @return \Illuminate\Database\Eloquent\Model|null
 * @throws \League\OAuth2\Server\Exception\OAuthServerException
 */
public function findAndValidateForPassportSms(Request $request)
{
    try {
                Validator::make($request->all(), [
                    'phone' => [
                        'required',
                        'min:11',
                        'max:11',
                        'regex:/^1[34578]{1}[\d]{9}$|^166[\d]{8}$|^19[89]{1}[\d]{8}$/',
                    ],
                    'verifyCode' => [
                        'required',
                        'max:6',
                        function ($attribute, $value, $fail) use ($request) {
                            if (!SmsVerifyCodeService::make($request->phone)->validate($value, false)) {
                                return $fail($attribute . ' is invalid.');
                            }
                        },
                    ]
                ])->validate();
                return static::phone($request->phone)->first();
            } catch (\Exception $e) {
                throw OAuthServerException::accessDenied($e->getMessage());
            }
}
```

In this example, the app is able to authenticate a user based on an `phone` and ``verifyCode property from a submitted JSON payload. It will return `null` or a user object. It also might throw exceptions explaining why the token is invalid. The `byPassportSmsRequest` catches any of those exceptions and converts them to appropriate OAuth exception type. If an `phone` is not present on the request payload, then we return `null` which returns an **invalid\_credentials** error response:

```
{
  "error": "invalid_credentials",
  "message": "The user credentials were incorrect."
}
```

Credits:
--------

[](#credits)

-

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~49 days

Total

7

Last Release

1590d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/534cdb651e8c806590fa945c6b5a18f361613848e890db1349f4a9fbcae1a650?d=identicon)[xutongle](/maintainers/xutongle)

---

Top Contributors

[![xutongle](https://avatars.githubusercontent.com/u/46956076?v=4)](https://github.com/xutongle "xutongle (11 commits)")[![xutl](https://avatars.githubusercontent.com/u/20939388?v=4)](https://github.com/xutl "xutl (2 commits)")

---

Tags

laravelsmslaravelsmspassport

### Embed Badge

![Health badge](/badges/larva-laravel-passport-sms/health.svg)

```
[![Health](https://phpackages.com/badges/larva-laravel-passport-sms/health.svg)](https://phpackages.com/packages/larva-laravel-passport-sms)
```

###  Alternatives

[corbosman/laravel-passport-claims

Add claims to Laravel Passport JWT Tokens

88655.9k](/packages/corbosman-laravel-passport-claims)[jeremy379/laravel-openid-connect

OpenID Connect support to the PHP League's OAuth2 Server. Compatible with Laravel Passport.

55342.3k2](/packages/jeremy379-laravel-openid-connect)[schedula/laravel-passport-socialite

The missing laravel passport feature for social authentication

4922.6k](/packages/schedula-laravel-passport-socialite)[rinvex/laravel-authy

Rinvex Authy is a simple wrapper for Authy TOTP, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

3376.7k1](/packages/rinvex-laravel-authy)[danjdewhurst/laravel-passport-facebook-login

Facebook Token Request Grant for Laravel Passport

2824.4k](/packages/danjdewhurst-laravel-passport-facebook-login)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
