Refactored grant type logic & json structs