Adding page remotely and authenticating users via custom login authentication type

Permalink 1 user found helpful
Hello all!

I am in a process of building an external system for a client which will be posting in to the C5 website and create pages.
I have a php file created under tools already which is working for most parts.
<?php
defined('C5_EXECUTE') or die("Access Denied.");
use Concrete\Core\Page\Type\Type;
$u = new User;
$u->loginByUserID('77', true);
if ($u->isLoggedIn()) {
  echo "last online::" .$u->checkLogin() ."<br>";
  echo "User groups::" .$u->getUserGroups()."<br>";
  foreach ($u->getUserGroups() as $group)
  echo "group::" .$group ."<br>";
}
echo 'User name::'. $u->getUserName();
Loader::model('collection_types');
$pr = Page::getByPath('/blog');
$data = array();


As you may see this code is checking for the user and if its a logged in session. For running the app, I have forced logged in the user and this is all good. This obviously cant be deployed as there are many users trying to hit the c5 site to post the pages. What would I have to do to make it work with the AuthenticationTypeHandler or similar way to check the OAuth token from the user and then add the page. Is there a way to look for the token and pass it here in the code above?

I know this token would be generated in the remote application but how do I validate the token here in C5 website?

Any help in this regard will definitely be appreciated and I will be able to move ahead.

Thanks!