getAccessTokenEndpoint = Config::get('unity.url').Config::get('unity.endpoint.login'); $this->username = Config::get('unity.auth.login.username'); $this->password = Config::get('unity.auth.login.password'); $this->apiKey = Config::get('unity.auth.api_key.key'); } public function execute(){ //Note: Cache access token base on expiry from login not ideal as token may gets overwritten if user login Unity dashboard $accessToken=''; if(empty($this->apiKey)){ $response = Http::post($this->getAccessTokenEndpoint, [ 'email' => $this->username, 'password' => $this->password , ])->object(); $accessToken = $response->access_token; }else{ $accessToken = $this->apiKey; } //TODO: Throw error if access token not available return $accessToken; } }