Add missing grant  for OAuth2 first party apps using username and password to get access_token.
Delete extra space in if, fixes typo.