PHPackages                             stephencoduor/oauth2-canvaslms - 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. stephencoduor/oauth2-canvaslms

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

stephencoduor/oauth2-canvaslms
==============================

Canvas LMS OAuth 2.0 support for the PHP 7.4 and above

v1.0.0(3y ago)03MITPHPPHP &gt;=7.4

Since Nov 1Pushed 3y ago1 watchersCompare

[ Source](https://github.com/stephencoduor/oauth2-canvaslms)[ Packagist](https://packagist.org/packages/stephencoduor/oauth2-canvaslms)[ RSS](/packages/stephencoduor-oauth2-canvaslms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Canvas LMS Provider for OAuth 2.0 Client php 7.4 and above
==========================================================

[](#canvas-lms-provider-for-oauth-20-client-php-74-and-above)

[![Latest Version](https://camo.githubusercontent.com/b17409a0f88208de1e6756b43d35b465f7371b2ad6e734e8dc629f3fe256f938/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374657068656e636f64756f722f6f61757468322d63616e7661736c6d732e737667)](https://packagist.org/packages/stephencoduor/oauth2-canvaslms)

This package provides Canvas LMS OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).

Install
-------

[](#install)

Require the package as below

```
composer require stephencoduor/oauth2-canvaslms

```

Use
---

[](#use)

Same as the League's OAuth client, using `\stephencoduor\OAuth2\Client\Provider\CanvasLMS` as the provider. Note that you can (and really should) include a `purpose` option parameter and you will need to include your `canvasInstanceUrl`.

Per the [Canvas OAUth docs](https://canvas.instructure.com/doc/api/file.oauth.html#oauth2-flow-0):

> For Canvas Cloud (hosted by Instructure), you can request a client ID and secret from  in the Dev Key Signup section.
>
> For open source Canvas users, you can generate a client ID and secret in the Site Admin account of your Canvas install. There will be a "Developer Keys" tab on the left navigation sidebar.

A small example:

```
use stephencoduor\OAuth2\Client\Provider\CanvasLMS;

session_start();

/* anti-fat-finger constant definitions */
define('CODE', 'code');
define('STATE', 'state');
define('STATE_LOCAL', 'oauth2-state');

/* Instantiate the class and pass the required configs ie clientId ,clientSecret, and urls */
$provider = new CanvasLMS([
    'clientId' => '676434567890',
    'clientSecret' => 'A8h7dZy6i4QS4GkBqrWUxr9jUdgcZobpVMCEBmOGMNa2D3Ab478A',
    'purpose' => 'Application Name here',
    'redirectUri' => 'https://' . $_SERVER['SERVER_NAME'] . '/' . $_SERVER['SCRIPT_NAME'],
    'canvasInstanceUrl' => 'https://canvas.instructure.com'
]);

/* if we don't already have an authorization code, let's get one! */
if (!isset($_GET[CODE])) {
    $authorizationUrl = $provider->getAuthorizationUrl();
    $_SESSION[STATE_LOCAL] = $provider->getState();
    header("Location: $authorizationUrl");
    exit;

/* check that the passed state matches the stored state to mitigate cross-site request forgery attacks */
} elseif (empty($_GET[STATE]) || $_GET[STATE] !== $_SESSION[STATE_LOCAL]) {
    unset($_SESSION[STATE_LOCAL]);
    exit('Invalid state');

} else {
    /* try to get an access token (using our existing code) */
    $token = $provider->getAccessToken('authorization_code', [CODE => $_GET[CODE]]);

    /* do something with that token... (probably not just print to screen, but whatevs...) */
    echo $token->getToken();
    exit;
}
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1294d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4972940?v=4)[stephen](/maintainers/stephencoduor)[@stephencoduor](https://github.com/stephencoduor)

---

Top Contributors

[![stephencoduor](https://avatars.githubusercontent.com/u/4972940?v=4)](https://github.com/stephencoduor "stephencoduor (2 commits)")

### Embed Badge

![Health badge](/badges/stephencoduor-oauth2-canvaslms/health.svg)

```
[![Health](https://phpackages.com/badges/stephencoduor-oauth2-canvaslms/health.svg)](https://phpackages.com/packages/stephencoduor-oauth2-canvaslms)
```

###  Alternatives

[league/oauth2-google

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

41721.2M118](/packages/league-oauth2-google)[knpuniversity/oauth2-client-bundle

Integration with league/oauth2-client to provide services

83416.7M61](/packages/knpuniversity-oauth2-client-bundle)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

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

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.2M7](/packages/microsoft-kiota-authentication-phpleague)

PHPackages © 2026

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