Skip to content

Commit

Permalink
Make 2FA easier
Browse files Browse the repository at this point in the history
  • Loading branch information
Davincible committed Jan 24, 2022
1 parent 2289817 commit ee39b8c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (info *TwoFactorInfo) Login2FA(code string) error {
return err
}

// Process will open up the challenge url in a chromeium browser and
// Process will open up the challenge url in a chromium browser and
// take a screenshot. Please report the screenshot and printed out struct so challenge
// automation can be build in.
func (c *ChallengeError) Process() error {
Expand Down
1 change: 1 addition & 0 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ var (
// Account & Login Errors
ErrBadPassword = errors.New("Password is incorrect")
ErrTooManyRequests = errors.New("Too many requests, please wait a few minutes before you try again")
Err2FARequired = errors.New("Two Factor Autentication required. Please call insta.TwoFactorInfo.Login2FA(code)")

// Upload Errors
ErrInvalidFormat = errors.New("Invalid file type, please use one of jpeg, jpg, mp4")
Expand Down
16 changes: 8 additions & 8 deletions goinsta.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,24 +728,24 @@ func (insta *Instagram) verifyLogin(body []byte) error {
}

if res.Status != "ok" {
err := errors.New(
fmt.Sprintf(
"Failed to login: %s, %s",
res.ErrorType, res.Message,
),
)
insta.warnHandler(err)

switch res.ErrorType {
case "bad_password":
return ErrBadPassword
case "two_factor_required":
insta.TwoFactorInfo = res.TwoFactorInfo
insta.TwoFactorInfo.insta = insta
return Err2FARequired
case "checkpoint_challenge_required":
insta.Challenge = res.Challenge
insta.Challenge.insta = insta
}
err := errors.New(
fmt.Sprintf(
"Failed to login: %s, %s",
res.ErrorType, res.Message,
),
)
insta.warnHandler(err)
return err
}

Expand Down

0 comments on commit ee39b8c

Please sign in to comment.