PHPackages                             zsgogo/otpless-auth-sdk - 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. zsgogo/otpless-auth-sdk

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

zsgogo/otpless-auth-sdk
=======================

SDK for Backend PHP SDK for resolving idToken and more.

v0.0.2(2y ago)02MITPHP

Since Nov 13Pushed 2y agoCompare

[ Source](https://github.com/zsphpproject/otpless-php-auth-sdk)[ Packagist](https://packagist.org/packages/zsgogo/otpless-auth-sdk)[ RSS](/packages/zsgogo-otpless-auth-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

Merchant Integration Documentation(Backend PHP Auth SDK)
========================================================

[](#merchant-integration-documentationbackend-php-auth-sdk)

---

> ## A. OTPLessAuth Dependency
>
> [](#a-otplessauth-dependency)
>
> install Below dependency in your project's

```
composer require otpless/otpless-auth-sdk
```

you can also get latest version of dependency at

---

> ## B. OTPLessAuth class
>
> [](#b-otplessauth-class)

The `OtplessAuth` class provides methods to integrate OTPLess authentication into your PHP backend application. This documentation explains the usage of the class and its methods.

### Methods:

[](#methods)

---

> ### 1. decodeIdToken
>
> [](#1-decodeidtoken)

---

This method help to resolve `idToken(JWT token)` which is issued by `OTPLess` which return user detail from that token also this method verify that token is valid, token should not expired and issued by only `otpless.com`

##### Method Signature:

[](#method-signature)

```
decodeIdToken(id_token, client_id, client_secret, audience=None)
```

#### Method Params:

[](#method-params)

ParamsData typeMandatoryConstraintsRemarksidTokenStringtrueidToken which is JWT token which you get from `OTPLess` by exchange code APIclientIdStringtrueYour OTPLess `Client Id`clientSecretStringtrueYour OTPLess `Client Secret`#### Return

[](#return)

Return: Object Name: UserDetail

```
{'success': True, 'auth_time': 1697649943, 'phone_number': '+9193******', 'email': 'dev***@gmail.com', 'name': 'Devloper From OTP-less', 'country_code': '+91', 'national_phone_number': '9313******'}
```

> ### 2. verify code
>
> [](#2-verify-code)

---

This method help to resolve `code` which is return from `OTPLess` which will return user detail from that code also this method verify that code is valid, code should not expired and issued by only `otpless.com`

##### Method Signature:

[](#method-signature-1)

```
verifyCode(code, client_id, client_secret)
```

#### Method Params:

[](#method-params-1)

ParamsData typeMandatoryConstraintsRemarkscodeStringtruecode which you get from `OTPLess`clientIdStringtrueYour OTPLess `Client Id`clientSecretStringtrueYour OTPLess `Client Secret`#### Return

[](#return-1)

Return: Object Name: UserDetail

```
{'success': True, 'auth_time': 1697649943, 'phone_number': '+9193******', 'email': 'dev***@gmail.com', 'name': 'Devloper From OTP-less', 'country_code': '+91', 'national_phone_number': '9313******'}
```

> ### 3. Verify Auth Token
>
> [](#3-verify-auth-token)

---

This method help to resolve `token` which is issued by `OTPLess` which return user detail from that token also this method verify that token is valid, token should not expired and issued by only `otpless.com`

##### Method Signature:

[](#method-signature-2)

```
verifyToken(token, client_id, client_secret)
```

#### Method Params:

[](#method-params-2)

ParamsData typeMandatoryConstraintsRemarkstokenStringtruetoken which you get from `OTPLess`clientIdStringtrueYour OTPLess `Client Id`clientSecretStringtrueYour OTPLess `Client Secret`#### Return

[](#return-2)

Return: Object Name: UserDetail

```
{'success': True, 'auth_time': 1697649943, 'phone_number': '+9193******', 'email': 'dev***@gmail.com', 'name': 'Devloper From OTP-less', 'country_code': '+91', 'national_phone_number': '9313******'}
```

---

> ### 4. Generate Magic link
>
> [](#4-generate-magic-link)

---

The Authorization Endpoint initiates the authentication process by sending a `magic link` to the user's WhatsApp or email, based on the provided contact information. This link is used to verify the identity of the user. Upon the user's action on this link, they are redirected to the specified URI with an authorization code included in the redirection.

##### Method Signature:

[](#method-signature-3)

```
generateMagicLink(mobile_number, email, client_id, client_secret,redirect_uri,channel)
```

#### Method Params:

[](#method-params-3)

ParamsData typeMandatoryConstraintsRemarkschannelStringfalseif no channel given WHATSAPP is chosen as defaultWHATSAPP/SMSmobile\_numberStringfalseAt least one requiredThe user's mobile number for authentication in the format: country code + number (e.g., 91XXXXXXXXXX)emailStringfalseAt least one requiredThe user's email address for authentication.redirect\_uriStringtrueThe URL to which the user will be redirected after authentication. This should be URL-encodedclientIdStringtrueYour OTPLess `Client Id`clientSecretStringtrueYour OTPLess `Client Secret`#### Return

[](#return-3)

Return: Object Name: RquestIds

```
{"requestIds":[{"type":"MOBILE","value":"ac48690347c24c0b8b54270590392b2a"}],"success":true}
```

### Example of usage

[](#example-of-usage)

```
require '../vendor/autoload.php';

use Otpless\OTPLessAuth;

// Your ID token to decode
$token = 'your token here';

$clientId = 'your client id here';
$clientSecret = 'your client secret here';
// Initialize the library class
$auth = new OtplessAuth();

$auth->verifyToken($token,$clientId,$clientSecret);
```

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

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 ~18 days

Total

2

Last Release

891d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/143f27b00010bd838d6c43f06eee08769314d50e029430d87f9f9215aac021b3?d=identicon)[a23743335](/maintainers/a23743335)

### Embed Badge

![Health badge](/badges/zsgogo-otpless-auth-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/zsgogo-otpless-auth-sdk/health.svg)](https://phpackages.com/packages/zsgogo-otpless-auth-sdk)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M161](/packages/google-auth)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M672](/packages/laravel-socialite)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[clerkinc/backend-php

2755.0k](/packages/clerkinc-backend-php)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2369.5k3](/packages/kinde-oss-kinde-auth-php)

PHPackages © 2026

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