When you switch from Live to Sandbox and the other way around you should care for the config
of the mode.
Sadly I did this all in PHP, not with MPL SDK but this piece of code might be the right hint to you:
LIVE:
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential('XXXXXXXXX...XXXXXXXXXX','YYYYYYY...YYYYYYYYY')
);
$apiContext->setConfig( array('mode' => 'live') );
SANDBOX:
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential('xxxxxxxxx...xxxxxxxxxx','yyyyyyyyyy...yyyyy')
);
$apiContext->setConfig(array('mode' => 'sandbox'));
Do not forget to set your Mode according to your credentials (Secret Key). Paypal does not recognize the type of secret-key by its own.