public function get_token_by_id_with_details($tokenid) {
        global $DB;
        $sql = "SELECT t.id, t.token, u.id AS userid, u.firstname, u.lastname, s.name, t.creatorid
                FROM {external_tokens} t, {user} u, {external_services} s
                WHERE t.id=? AND t.tokentype = ? AND s.id = t.externalserviceid AND t.userid = u.id";
        $token = $DB->get_record_sql($sql, array($tokenid, EXTERNAL_TOKEN_PERMANENT), MUST_EXIST);
        return $token;
    }
public function get_token_by_id_with_details($tokenid) {
        global $DB;
        $sql = "SELECT t.id, t.token, u.id AS userid, u.firstname, u.lastname, s.name, t.creatorid
                FROM {external_tokens} t, {user} u, {external_services} s
                WHERE t.id=? AND t.tokentype = ? AND s.id = t.externalserviceid AND t.userid = u.id";
        $token = $DB->get_record_sql($sql, array($tokenid, EXTERNAL_TOKEN_PERMANENT), MUST_EXIST);
        return $token;
    }
public function get_token_by_id_with_details ( $ tokenid ) { global $ DB ; $ sql = "SELECT t.id, t.token, u.id AS userid, u.firstname, u.lastname, s.name, t.creatorid
                FROM {external_tokens} t, {user} u, {external_services} s
                WHERE t.id=? AND t.tokentype = ? AND s.id = t.externalserviceid AND t.userid = u.id" ; $ token = $ DB -> get_record_sql ( $ sql , array ( $ tokenid , EXTERNAL_TOKEN_PERMANENT ) , MUST_EXIST ) ; return $ token ; }
Return a token of an arbitrary user by tokenid, including details of the associated user and the service name.
If no tokens exist an exception is thrown

The returned value is a stdClass:
->id token id
->token
->firstname user firstname
->lastname
->name service name

@param int $tokenid token id
@return stdClass
Return a token of an arbitrary user by tokenid including details of the associated user and the service name . If no tokens exist an exception is thrown