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

Abandoned → [groton-school/oauth2-canvaslms](/?search=groton-school%2Foauth2-canvaslms)ArchivedLibrary[Authentication &amp; Authorization](/categories/authentication)

smtech/oauth2-canvaslms
=======================

Canvas LMS OAuth 2.0 support for the PHP League's OAuth 2.0 Client

v1.0(9y ago)1121.9k↓53.1%12[1 issues](https://github.com/smtech/oauth2-canvaslms/issues)1MITPHPPHP &gt;=5.5.0

Since Jul 14Pushed 6y ago2 watchersCompare

[ Source](https://github.com/smtech/oauth2-canvaslms)[ Packagist](https://packagist.org/packages/smtech/oauth2-canvaslms)[ RSS](/packages/smtech-oauth2-canvaslms/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

Canvas LMS Provider for OAuth 2.0 Client
========================================

[](#canvas-lms-provider-for-oauth-20-client)

[![Latest Version](https://camo.githubusercontent.com/b5e9dfeb24dd3a62af0be346391a605730eff25ce72d1a3ba8a1e1fe31d478e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736d746563682f6f61757468322d63616e7661736c6d732e737667)](https://packagist.org/packages/smtech/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)

In your `composer.json`, include:

```
"require": {
    "smtech/oauth2-canvaslms": "~1.0"
}
```

Use
---

[](#use)

Same as the League's OAuth client, using `\smtech\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 smtech\OAuth2\Client\Provider\CanvasLMS;

session_start();

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

$provider = new CanvasLMS([
    'clientId' => '160000000000127',
    'clientSecret' => 'z4RUroeMI0uuRAA8h7dZy6i4QS4GkBqrWUxr9jUdgcZobpVMCEBmOGMNa2D3Ab4A',
    'purpose' => 'My App Name',
    '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

36

—

LowBetter than 79% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

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

3642d ago

### Community

Maintainers

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

---

Top Contributors

[![battis](https://avatars.githubusercontent.com/u/419619?v=4)](https://github.com/battis "battis (1 commits)")[![hcientist](https://avatars.githubusercontent.com/u/351751?v=4)](https://github.com/hcientist "hcientist (1 commits)")

### Embed Badge

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

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[thenetworg/oauth2-azure

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

25310.7M83](/packages/thenetworg-oauth2-azure)[league/oauth2-google

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

42223.4M176](/packages/league-oauth2-google)[stevenmaguire/oauth2-keycloak

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

2306.4M45](/packages/stevenmaguire-oauth2-keycloak)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[patrickbussmann/oauth2-apple

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

1152.8M12](/packages/patrickbussmann-oauth2-apple)

PHPackages © 2026

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