2017 © Pedro Peláez
 

library oauth2-discord

OAuth2 client for authenticating with the Discord API servers

image

team-reflex/oauth2-discord

OAuth2 client for authenticating with the Discord API servers

  • Friday, October 7, 2016
  • by uniquoooo
  • Repository
  • 2 Watchers
  • 35 Stars
  • 5,816 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 19 Forks
  • 12 Open issues
  • 2 Versions
  • 9 % Grown

The README.md

oauth2-discord

Build Status Coverage Status, (*1)

Provides Discord OAuth 2.0 support for PHP League's OAuth 2.0 Client., (*2)

Installation

Run composer require team-reflex/oauth2-discord., (*3)

Usage

<?php

$provider = new \Discord\OAuth\Discord([
    'clientId'     => 'oauth-app-id',
    'clientSecret' => 'oauth-app-secret',
    'redirectUri'  => 'http://your.redirect.url',
]);

if (! isset($_GET['code'])) {
    echo '<a href="'.$provider->getAuthorizationUrl().'">Login with Discord</a>';
} else {
    $token = $provider->getAccessToken('authorization_code', [
        'code' => $_GET['code'],
    ]);

    // Get the user object.
    $user = $provider->getResourceOwner($token);

    // Get the guilds and connections.
    $guilds = $user->guilds;
    $connections = $user->connections;

    // Accept an invite
    $invite = $user->acceptInvite('https://discord.gg/0SBTUU1wZTUo9F8v');

    // Get a refresh token
    $refresh = $provider->getAccessToken('refresh_token', [
        'refresh_token' => $getOldTokenFromMemory->getRefreshToken(),
    ]);

    // Store the new token.
}

Credits

License

This code is subject to the MIT license which can be found in the LICENSE file., (*4)

The Versions

07/10 2016

dev-master

9999999-dev

OAuth2 client for authenticating with the Discord API servers

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole

21/06 2016

v1.0

1.0.0.0

OAuth2 client for authenticating with the Discord API servers

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Cole