api: fix token assignment.

Closes #127.