Closed Tsumiki-Chan closed 8 years ago
Same.
Just a small update on this one.
You have to request the "guilds" scope which is not requested by default. Plus you can't change the scopes using this small "api". You'll have to change the getDefaultScopes
function in order to get the required privileges.
It still shouldn't return objects with all Items being null tho. I'd fix up this class but unfortunately I haven't got the time for it atm.
By default the library only requests identify
and email
because this is basic OAuth2 information, if you need guilds you will need to pass through the scopes when you generate the authorization URL:
$provider->getAuthorizationUrl([
'scope' => [
'identify',
'email',
'guilds',
],
]);
@uniquoooo still nothing. I use this code to generate the authorization url with the guilds scope (and it works, I get the authorization url with these scopes)
$this->get('oauth2.registry')
->getClient('discord')
->redirect(['guilds','identify','email']);
And using this code to get the user's guilds:
$client = $this->get('oauth2.registry')
->getClient('discord');
$user = $client->fetchUser();
var_dump($user->getGuildsAttribute());
I receive: private 'guilds' => string '[{},{},{},{},{},{},{}]' (length=22)
Still it shouldnt return obects with all values being null, should it?
@chonsser Wrong usage:
It's $user->guilds
When you call $user->guilds you'll get a couple of objects in which all values are NULL.
object(Illuminate\Support\Collection)#45 (1) { ["items":protected]=> array(2) { [0]=> object(Discord\OAuth\Parts\Guild)#48 (5) { ["id"]=> NULL ["name"]=> NULL ["icon"]=> NULL ["owner"]=> NULL ["permissions"]=> NULL } [1]=> object(Discord\OAuth\Parts\Guild)#41 (5) { ["id"]=> NULL ["name"]=> NULL ["icon"]=> NULL ["owner"]=> NULL ["permissions"]=> NULL } } }