scope)); } public function refresh() { $rsp = Http::post('https://id.twitch.tv/oauth2/token', [ 'client_id' => config('twitch.client_id'), 'client_secret' => config('twitch.client_secret'), 'grant_type' => 'refresh_token', 'refresh_token' => $this->refresh, ]); if (!$rsp->successful()) { throw new \Exception($rsp['message']); } $this->type = $rsp['token_type']; $this->scope = $rsp['scope']; $this->access = $rsp['access_token']; $this->refresh = $rsp['refresh_token']; $this->save(); } protected $casts = [ 'scope' => 'array', ]; protected $hidden = [ 'access', 'refresh', ]; }