.'&scope='.implode('+', array_map('rawurlencode', $this->scope));
}
+ public function hasExpired() {
+ return now()->isAfter($this->expires_at);
+ }
+
public function refresh() {
$rsp = Http::post('https://id.twitch.tv/oauth2/token', [
'client_id' => config('twitch.client_id'),
$this->scope = $rsp['scope'];
$this->access = $rsp['access_token'];
$this->refresh = $rsp['refresh_token'];
+ $this->expires_at = now()->add($rsp['expires_in'], 'second');
$this->save();
}