Fixes bad authorization logic when leveraging metadata service

... We forgot to include the security token. I also tweaked the code a bit.