protected function getDeviceToken(){
		// check if valid device token exists
		$deviceToken = $this->getConfig()->getStorage()->getDeviceToken();
		if(null !== $deviceToken && $deviceToken->isExpired()){
			$this->getConfig()->getStorage()->deleteDeviceToken();
			$deviceToken = null;
		}
		
		if(null === $deviceToken){
			// if no token exists, call the code endpoint
			$params = array(
				'client_id' => $this->getConfig()->getClientId(),
				'scope' => $this->getConfig()->getScope(),
			);
			$response = $this->sendPostRequest("oauth2waitress/oauth2.svc/code", $params);
			$output = $response['output'];
			$httpcode = $response['code'];
			switch($httpcode){
				case "200" : 
					// save the recieved DeviceToken
					$responseObject = json_decode($output);
					$deviceToken = new DeviceToken(new DateTime(), $responseObject->device_code, $responseObject->expires_in, $responseObject->interval, $responseObject->user_code, $responseObject->verification_url);
					$this->getConfig()->getStorage()->saveDeviceToken($deviceToken);
			}
		}
		return $deviceToken;
	}
protected function getDeviceToken(){
		// check if valid device token exists
		$deviceToken = $this->getConfig()->getStorage()->getDeviceToken();
		if(null !== $deviceToken && $deviceToken->isExpired()){
			$this->getConfig()->getStorage()->deleteDeviceToken();
			$deviceToken = null;
		}
		
		if(null === $deviceToken){
			// if no token exists, call the code endpoint
			$params = array(
				'client_id' => $this->getConfig()->getClientId(),
				'scope' => $this->getConfig()->getScope(),
			);
			$response = $this->sendPostRequest("oauth2waitress/oauth2.svc/code", $params);
			$output = $response['output'];
			$httpcode = $response['code'];
			switch($httpcode){
				case "200" : 
					// save the recieved DeviceToken
					$responseObject = json_decode($output);
					$deviceToken = new DeviceToken(new DateTime(), $responseObject->device_code, $responseObject->expires_in, $responseObject->interval, $responseObject->user_code, $responseObject->verification_url);
					$this->getConfig()->getStorage()->saveDeviceToken($deviceToken);
			}
		}
		return $deviceToken;
	}
protected function getDeviceToken ( ) { // check if valid device token exists $ deviceToken = $ this -> getConfig ( ) -> getStorage ( ) -> getDeviceToken ( ) ; if ( null !== $ deviceToken && $ deviceToken -> isExpired ( ) ) { $ this -> getConfig ( ) -> getStorage ( ) -> deleteDeviceToken ( ) ; $ deviceToken = null ; } if ( null === $ deviceToken ) { // if no token exists, call the code endpoint $ params = array ( 'client_id' => $ this -> getConfig ( ) -> getClientId ( ) , 'scope' => $ this -> getConfig ( ) -> getScope ( ) , ) ; $ response = $ this -> sendPostRequest ( "oauth2waitress/oauth2.svc/code" , $ params ) ; $ output = $ response [ 'output' ] ; $ httpcode = $ response [ 'code' ] ; switch ( $ httpcode ) { case "200" : // save the recieved DeviceToken $ responseObject = json_decode ( $ output ) ; $ deviceToken = new DeviceToken ( new DateTime ( ) , $ responseObject -> device_code , $ responseObject -> expires_in , $ responseObject -> interval , $ responseObject -> user_code , $ responseObject -> verification_url ) ; $ this -> getConfig ( ) -> getStorage ( ) -> saveDeviceToken ( $ deviceToken ) ; } } return $ deviceToken ; }
Retrieves DeviceToken contianing the UserCode and DeviceCode
@return DeviceToken
Retrieves DeviceToken contianing the UserCode and DeviceCode