Only try to delete token if the token create succeeded

Otherwise the code tries to access 'data' which might
not be valid JSON.

(cherry picked from commit 34bbba8135538d3fc3631723ec46b6ea92c38d49)
add travis testing support

(cherry picked from commit 27822fd04b8409556ffd6f2678cf2e4d8eabc3af)