added checks for failed authorization lookup and malformed uri