How to handle password field for externally authenticated users (Oauth2)?
It depends on how you want Oauth integration to work.

If the Oauth integration is a supplement, then you should let users define a password themselves, so they can either login with username/password or Oauth. If you don't want users to login directly on the Drupal site with credentials but only use Oauth, you can use user_external_login_register. This willassign a random password to the user, since the password property is required, a random password is generated on the fly:

...
$userinfo = array(
  'name' =&gt; $name,
  'pass' =&gt; user_password(),
  'init' =&gt; $name,
  'status' =&gt; 1,
  'access' =&gt; REQUEST_TIME,
);
$account = user_save(drupal_anonymous_user(), $userinfo);
...