oauth2
Deprecated This will be removed in the 1.0.0 version of Isomorphic-Git.
This functionality is now provided by the
oauth2format
andtoken
arguments
param | type [= default] |
---|---|
company | string |
token | string |
return | {username: string, password: string} |
Use with push and fetch to set Basic Authentication headers. This for is for actual OAuth2 tokens (not "personal access tokens"). Unfortunately, all the major git hosting companies have chosen different conventions! Lucky for you, I already looked up and codified it for you.
- oauth2('github', token) - GitHub uses
token
as the username, and'x-oauth-basic'
as the password. - oauth2('githubapp', token) - GitHub Apps use
'x-access-token'
as the username, andtoken
as the password. - oauth2('bitbucket', token) - Bitbucket uses
'x-token-auth'
as the username, andtoken
as the password. - oauth2('gitlab', token) - GitLab uses
'oauth2'
as the username, andtoken
as the password.
I will gladly accept pull requests for more companies' conventions.
let credentials = git.utils.oauth2('github', 'token')
console.log(credentials)
credentials = git.utils.oauth2('githubapp', 'token')
console.log(credentials)
credentials = git.utils.oauth2('bitbucket', 'token')
console.log(credentials)
credentials = git.utils.oauth2('gitlab', 'token')
console.log(credentials)