Closed ramtinak closed 5 years ago
I had the same problem. Comparing the application traffic I came to the conclusion that it depends on the parameter "device_id":"android-8907s3f76g3s4641". If you put a value from a real device, this error does not occur.
@ramtinak Can you please add this changes also in nuget library?
Also helps to change the ip
@DenisKrsk I think you are wrong! This challenge is this one:
This is happened while you are trying to login with another device and IP address and this challenge will pop up to your logged account in other device.
It doesn't related to LoginAsync
at all!.
Also using a real device id it's on you, you can use actual device id for your own login using custom device.
We can't set real device id because so many people using InstagramApiSharp so we just create a new GUID for each login.
@sopranidaniele I will update it tonight.
I found an issue in the AcceptChallengeAsync() function.
It throws this Exception:
user must be authenticated at InstagramApiSharp.Helpers.UserAuthValidator.Validate(UserAuthValidate userAuthValidate) at InstagramApiSharp.API.InstaApi.AcceptChallengeAsync()
that's the code:
var res = await Api.VerifyCodeForChallengeRequireAsync(code);
switch (res.Value)
{
case InstaLoginResult.ChallengeRequired:
var result = await Api.AcceptChallengeAsync(); //Exception
break;
}
This Exception is thrown only sometimes by some users.
@sopranidaniele This isn't a bug related to AcceptChallengeAsync
!
You CANNOT use AcceptChallengeAsync
for login challenge!
This is for users that already logged in and passed default challenge(if any) and IsUserAuthenticated
are TRUE
(successfully logins).
As you can see here, I didn't put the accepting challenge code for VerifyCodeForChallengeRequireAsync(code);
or any other challenge function!
https://github.com/ramtinak/InstagramApiSharp/blob/42a5f6cdbb8d82838ca29c94ca5a544122b9232a/samples/ChallengeRequireExample/Form1.cs#L377-L390
This is for all other functions (get thread, send message, follower/followings list, follow/unfollow, like/unlike, uploading video/image/album, get story and etc.) if you across to Challenge while you requesting for these functions, you just simply accept it without doing new re-login!
Please read this comments in ChallengeExample project: https://github.com/ramtinak/InstagramApiSharp/blob/85a4bb3e5911bf27d5aa5ad87d0e5bbd9aae60f6/samples/ChallengeRequireExample/Form1.cs#L41-L83
ops I'm sorry, but what I have to do if the response for VerifyCodeForChallengeRequireAsync(code) is InstaLoginResult.ChallengeRequired?
@sopranidaniele Please check https://github.com/ramtinak/InstagramApiSharp/blob/master/samples/ChallengeRequireExample/Form1.cs and read comments.
I read all the comments, i understood how to use AcceptChallenge function, but when I send the verification code to solve the challenge (VerifyCodeForChallengeRequireAsync), the response type is InstaLoginResult.ChallengeRequired. I only want to know how to handle this event.
In your Example there is not explained how to handle that event, you only show to handle it when the response is InstaLoginResult.TwoFactorRequired.
Issue category
Language
Usage
Debug logs
Describe your issue
This will be a fix for
Challenge while you already logged in
.Screenshot