Added extension/pin validity check, DRYed the RESTclient.