Skip to content

Instantly share code, notes, and snippets.

@colinrymer
Created February 21, 2018 20:49
Show Gist options
  • Save colinrymer/ef13b71bb7ef9022b5807baac08bbc37 to your computer and use it in GitHub Desktop.
Save colinrymer/ef13b71bb7ef9022b5807baac08bbc37 to your computer and use it in GitHub Desktop.
Example api client code
import * as Octokit from '@octokit/rest'
const client = new Octokit()
export default class GithubClient {
public static async authenticate({username, password, twoFactorCode}: any) {
client.authenticate({
type: 'basic',
username: username,
password: password
})
const {data: {token}} = await client.authorization.create({
scopes: ['repo'],
headers: {
'x-github-otp': twoFactorCode
}
} as Octokit.AuthorizationCreateParams)
return token
}
}
@colinrymer
Copy link
Author

Currently, calling GithubClient.authenticate with a bogus twoFactorCode, e.g. '000000' for users that do not have 2FA enabled successfully returns a personal access token. Is this undocumented but expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment