Yoast's instructions inform people to use the following commands:
composer config -g http-basic.my.yoast.com token ...
composer config repositories.my-yoast composer https://my.yoast.com/packages/
composer require yoast/wordpress-seo-premium
To create the auth.json file though, you need to run the first command without -g; additionally, these commands should be run to generate the files, and not just added to the build script.