PHPackages                             rwandabuild/murugo\_api\_auth - 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. rwandabuild/murugo\_api\_auth

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

rwandabuild/murugo\_api\_auth
=============================

Package that will use Murugo auth to all 3rd party laravel projects with only API structure

v2.6.2(2y ago)93.6kMITPHP

Since May 6Pushed 2y ago2 watchersCompare

[ Source](https://github.com/RWBuild/package_MurugoAuth_API-Laravel)[ Packagist](https://packagist.org/packages/rwandabuild/murugo_api_auth)[ RSS](/packages/rwandabuild-murugo-api-auth/feed)WikiDiscussions test Synced 1mo ago

READMEChangelog (10)DependenciesVersions (68)Used By (0)

Laravel API Authentication with MurugoCloudCore Package
=======================================================

[](#laravel-api-authentication-with-murugocloudcore-package)

[![Issues](https://camo.githubusercontent.com/2e2f850bae7565a9d4cfe675477d1056c51930e9c81e77d58aa3b2913d18a815/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f52574275696c642f7061636b6167655f4d757275676f417574685f4150492d4c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/RWBuild/package_MurugoAuth_API-Laravel/issues)[![Stars](https://camo.githubusercontent.com/abe6af87b61c1fdbd237d2187bf367afba73a6c8c4646f73a1142658de30caed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f52574275696c642f7061636b6167655f4d757275676f417574685f4150492d4c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/RWBuild/package_MurugoAuth_API-Laravel/stargazers)[![Total Downloads](https://camo.githubusercontent.com/59106b2cf554e20639f45691884935fbb90ec37b41ceb98f027bfa4e44baa82f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7277616e64616275696c642f6d757275676f5f6170695f617574682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rwandabuild/murugo_api_auth)

Package that will be used for Murugo auth to all 3rd party laravel projects with only API structure

Follow the following steps to get started:
------------------------------------------

[](#follow-the-following-steps-to-get-started)

#### 1. Install package by running the following command

[](#1-install-package-by-running-the-following-command)

```
composer require rwandabuild/murugo_api_auth
```

#### 2. Include the following variables in config services file

[](#2-include-the-following-variables-in-config-services-file)

```
    'murugo' => [
        'client_id' => env('MURUGO_CLIENT_ID'),
        'client_secret' => env('MURUGO_CLIENT_SECRET'),
        'redirect' => env('APP_REDIRECT_URL', 'YOUR LOGIN REDIRECT URL'),
        'murugo_url' => env('MURUGO_URL', 'MURUGO_URL'),
        'murugo_app_key' => env('MURUGO_APP_KEY'),
    ],
```

#### 3. Dont forget to publish your migration by running the following command, when you want to upgrade

[](#3-dont-forget-to-publish-your-migration-by-running-the-following-command-when-you-want-to-upgrade)

```
php artisan vendor:publish
```

#### 4. Use the following migration

[](#4-use-the-following-migration)

```
php artisan migrate
```

#### 5. Add method to redirect user to murugo

[](#5-add-method-to-redirect-user-to-murugo)

```
   use RwandaBuild\MurugoAuth\Facades\MurugoAuth;

    public function redirectToMurugo()
    {
        return MurugoAuth::redirect();
    }
```

#### 6. Add a callback method to be used after the redirection

[](#6-add-a-callback-method-to-be-used-after-the-redirection)

```
   use RwandaBuild\MurugoAuth\Facades\MurugoAuth;

    public function murugoCallback()
    {
        $murugoUser = MurugoAuth::user()
    }
```

#### 7. Package also comes with this following method

[](#7-package-also-comes-with-this-following-method)

```
    /**
     * This one is used by client(mobile) to authenticate murugo users on their 3rd party servers
     */
   use RwandaBuild\MurugoAuth\Facades\MurugoAuth;
   $tokens = [
               'access_token' => 'murugo_user_access_token'],
              'refresh_token' => 'murugo_user_refresh_token',
              'expires_in' => integer
   ],
   $murugoUser = MurugoAuth::userFromToken($tokens);
```

#### 8. Add relationship between User and Murugo User models

[](#8-add-relationship-between-user-and-murugo-user-models)

- Add a Trait built in the package already that makes relationship between User model and Murugo user model

```
    use RwandaBuild\MurugoAuth\Traits\MurugoAuthHelper;
    class User extends Authenticatable
    {
      use MurugoAuthHelper;
    }
```

- To access the murugo user when you already have user model like the following:

```
    $user = User::find(1);
    // access the relationship
    $murugoUser = $user->murugoUser;
```

- When you have a murugo user model and you need to the related user, you can do it in the following way:

```
$murugoUser = MurugoAuth::user();
// accessing the related user
$user = $murugoUser->user;
```

NOTES: By default package is using App\\User model or App\\Models|user for making relationship between your user and murugo user model

#### 9. At this step this is how you refresh tokens

[](#9-at-this-step-this-is-how-you-refresh-tokens)

First you should know that the Murugo user model keeps the `access_token` `refresh_token` and the `token_expires_at`, now in case you may need to refresh the token of an existing, just do it in the following way:

```
$user = User::find(2);

// refreshing murugo user token

$murugoUser = MurugoAuth::refreshToken($user->murugoUser);
```

By Default package will add the following api routes in your laravel project
----------------------------------------------------------------------------

[](#by-default-package-will-add-the-following-api-routes-in-your-laravel-project)

- api/murugo-auth &gt;&gt;&gt; This route will be used to get response sent from murugo and save in your laravel project database
- api/authenticate-user &gt;&gt;&gt;This route will authenticate user by checking uuid of user and by checking if token is still valid and if true return user object
- api/logout &gt;&gt;&gt; This route will logout user on murugo server

Follow RwandaBuild bellow and contact us
----------------------------------------

[](#follow-rwandabuild-bellow-and-contact-us)

- [Rwanda Build Website](https://rwandabuildprogram.com/)
- [Rwanda Build On Twitter](https://twitter.com/RwandaBuild)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 85.3% 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 ~22 days

Recently: every ~31 days

Total

58

Last Release

944d ago

Major Versions

v1.42 → v2.02020-09-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3a6d635b2bda9623418d599663a429096fa7a8fb02fffaca60da4af5a8126f1?d=identicon)[CommonWorld](/maintainers/CommonWorld)

---

Top Contributors

[![uwevanopfern](https://avatars.githubusercontent.com/u/10698517?v=4)](https://github.com/uwevanopfern "uwevanopfern (29 commits)")[![nshutiprince](https://avatars.githubusercontent.com/u/75612008?v=4)](https://github.com/nshutiprince "nshutiprince (2 commits)")[![WinnersProx](https://avatars.githubusercontent.com/u/34940230?v=4)](https://github.com/WinnersProx "WinnersProx (2 commits)")[![kakaprodo](https://avatars.githubusercontent.com/u/30261670?v=4)](https://github.com/kakaprodo "kakaprodo (1 commits)")

### Embed Badge

![Health badge](/badges/rwandabuild-murugo-api-auth/health.svg)

```
[![Health](https://phpackages.com/badges/rwandabuild-murugo-api-auth/health.svg)](https://phpackages.com/packages/rwandabuild-murugo-api-auth)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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