Firstly, you have to make sure that you have attached the policy to your IAM role.
Also, check if your F2A is enabled or not. If it is enabled then you won't get any option to use the aws ecr get-login, so you'll have to remove the 2FA from your account and you will get the authorization token.