It can be done via https and oauth or ssh.
https and oauth: create an access token that has “repo” scope and then use this syntax:
"package-name": "git+https://<github_token>:x-oauth-basic@github.com/<user>/<repo>.git"
or
ssh: setup ssh and then use this syntax:
"package-name": "git+ssh://git@github.com:<user>/<repo>.git"
(note the use of colon instead of slash before user)