The oauth.php file

Located in oauth/example/server/www/

This script is the one that calls each of the requests for the protocol between the two platforms, the integrating website and HP WallArt.
This "handshake" is established with the script to authenticate in three steps our application and to operate in a very secure manner.
We added to the oAuth library a new function authorizeFinish from the class OAuthServer, the variable $project_id, will be used to search in the table oauth_server_token the value that can identify the right project.

	$server = new OAuthServer();

	switch($_SERVER['PATH_INFO'])
	{
		case '/request_token':
		{
			$token = $server->requestToken();
		} break;
		
		case '/authorize':
		{
			assert_logged_in();
			
			//Get the logged in user id and the project id from the session.
			$user_id = get_logged_in();
			$project_id = get_project_id();
			
            try
			{
				$server->authorizeVerify();
				$server->authorizeFinish(true, $user_id, $project_id); //Pass the user id to this function.
				
			}
			catch (OAuthException2 $e)
			{
				header('HTTP/1.1 400 Bad Request');
				header('Content-Type: text/plain');
				
				echo "Failed OAuth Request FROM /authorize: " . $e->getMessage();
			}
		}
	
		case '/access_token':
		{
			$server->accessToken();
		} break;
		
		default:
		{
			header('HTTP/1.1 500 Internal Server Error');
			header('Content-Type: text/plain');
			echo "Unknown request";
		}
	}