Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

[WIP] Capcha Support #1788

Merged
merged 17 commits into from
Nov 9, 2016
Merged

[WIP] Capcha Support #1788

merged 17 commits into from
Nov 9, 2016

Conversation

Rover656
Copy link

@Rover656 Rover656 commented Nov 7, 2016

Closes issues

Changes

  • Adds Capcha Support

Change details

Using changes discussed in #1764 (It's a big conversation)

Other informations

It may not work, looking for people to test it.

@Rover656 Rover656 mentioned this pull request Nov 7, 2016
@@ -203,9 +231,25 @@ public static string CurrentVersion
/// </summary>
public static InventoryDelta InventoryDelta { get; private set; }

public static bool IsIncenseActive
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing a lot of unrelated changes like this line, can you please just add what's needed for captcha to work?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I will clean the code up tomorrow, I had multiple branches in the same folder

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fixed

}

private static async
Task
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix code format.

Copy link
Author

@Rover656 Rover656 Nov 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the unrelated code, will fix this problem tomorrow
EDIT: Oh, I see what you mean

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fixed

if (url.StartsWith("unity:"))
{
int index = url.IndexOf("unity:");
if (index != -1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this check is needed, if url starts with "unity:" then you can just take a substring starting from "unity:".Length. The else should be for the outer if.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will fix this tomorrow along with the. Csproj file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fixed

@ghost
Copy link

ghost commented Nov 7, 2016

@Rover656 Thanks for your effort. I have the code running in my phone. Just need to trigger captcha somehow.
Maybe some speeding would do the trick :)

@Rover656
Copy link
Author

Rover656 commented Nov 8, 2016

@ST-Apps The code is all fixed 😄

@WallyCZ
Copy link

WallyCZ commented Nov 8, 2016

CheckChallenge is already called with login in Login.cs:64 - you should use this response and don't call it again separately

@Rover656
Copy link
Author

Rover656 commented Nov 8, 2016

@WallyCZ How do you mean?

@Rover656
Copy link
Author

Rover656 commented Nov 8, 2016

@WallyCZ oh ok, how would we adapt this to use in the current situation?

@Rover656
Copy link
Author

Rover656 commented Nov 8, 2016

so it would look like this?:

    private async Task SetServer()
    {

        var serverRequest = RequestBuilder.GetInitialRequestEnvelope(
            new Request
            {
                RequestType = RequestType.GetPlayer,
                RequestMessage = new GetPlayerMessage().ToByteString()
            },
            new Request
            {
                RequestType = RequestType.CheckChallenge,
                RequestMessage = new CheckChallengeMessage().ToByteString()
            }
        );

        var serverResponse = await PostProto<Request>(Resources.RpcUrl, serverRequest);

        if(serverRequest.StatusCode == (int) StatusCode.AccessDenied)
        {
            throw new AccountLockedException();
        }

        if(serverResponse.ShowChallenge)
        {
            // Captcha is shown in checkChallengeResponse.ChallengeUrl
            Logger.Write($"ChallengeURL: {checkChallengeResponse.ChallengeUrl}");
            // breakpoint here to manually resolve Captcha in a browser
            // after that set token to str variable from browser (see screenshot)
            Logger.Write($"Pause");

            //GOTO THE REQUIRED PAGE
            BootStrapper.Current.NavigationService.Navigate(typeof(ChallengePage), checkChallengeResponse.ChallengeUrl);

            //await VerifyChallenge(token);
        }

        if (serverResponse.AuthTicket == null)
        {
            Client.AccessToken = null;
            throw new AccessTokenExpiredException();
        }

        Client.AccessToken.AuthTicket = serverResponse.AuthTicket;

        if (serverResponse.StatusCode == (int)StatusCode.Redirect)
        {
            Client.ApiUrl = serverResponse.ApiUrl;
        }
    }

@WallyCZ
Copy link

WallyCZ commented Nov 8, 2016

You should not call UI elements (Navigate) from API, so you can trigger in API some event or store ChallengeResponse object to be able to read it from client after login. But you found right place to hook it. If you want help just let me know

@Rover656
Copy link
Author

Rover656 commented Nov 8, 2016

Yea, could you help me please @WallyCZ i am not sure how this api works, i'm better with webviews and client sided programming

@WallyCZ
Copy link

WallyCZ commented Nov 8, 2016

I will on look it after work. Meantime please check if _client attribute is properly initialized in your .xaml.cs class.

@Rover656
Copy link
Author

Rover656 commented Nov 8, 2016

@WallyCZ no, i don't think so, i will look into it
EDIT: How would one do that?
EDIT: Just got some help, yes it is initialized:
private static Client _client;

@WallyCZ
Copy link

WallyCZ commented Nov 8, 2016

This will not work this way. Have you tested it? It will crash when first call _client. occurs. There is already one (properly initialized) static instance inside GameClient, so you must use this (through creating new method in GameClient). This is what you have already done but it seems you are not using it.

@Rover656
Copy link
Author

Rover656 commented Nov 8, 2016

Could you try to repair this?

@WallyCZ
Copy link

WallyCZ commented Nov 8, 2016

ok

@ghost
Copy link

ghost commented Nov 8, 2016

Just thinking... If the captcha is checked only when the user logs in how will he know in the middle of the game that he has been hit by captcha?
It's true that then you won't see mons or stops anymore, but so does exceeding the speed limit. How to tell the difference?
Edit: how does the official client behave to captcha?

@WallyCZ
Copy link

WallyCZ commented Nov 8, 2016

Request for captcha can virtually come with every response in original client. I'll try to do something similar, but this RocketAPI was not designed to fit these requirements...

@ghost
Copy link

ghost commented Nov 8, 2016

Got an account with pending captcha and having the following error with it:

wp_ss_20161108_0004

@WallyCZ
Copy link

WallyCZ commented Nov 9, 2016

@Rover656 Sent PR https://github.com/Rover656/PoGo-UWP/pull/3 to your repo so please merge it ;)

@Rover656
Copy link
Author

Rover656 commented Nov 9, 2016

Ok

Changes in API to make work check challenge correctly + Captcha tested and verified it works
@Rover656
Copy link
Author

Rover656 commented Nov 9, 2016

All ready for merge

@WallyCZ
Copy link

WallyCZ commented Nov 9, 2016

Sry, forgot to add this line to GameClient.cs:378:

apiFailureStrategy.OnFailureToggleUpdateTimer += ToggleUpdateTimer;

so it should look like this:

            var apiFailureStrategy = new ApiFailureStrategy(_client);
            _client.ApiFailure = apiFailureStrategy;
            // Register to AccessTokenChanged
            apiFailureStrategy.OnAccessTokenUpdated += (s, e) => SaveAccessToken();
            apiFailureStrategy.OnFailureToggleUpdateTimer += ToggleUpdateTimer;
        }

@Rover656 Could you do it? Thanks

@Rover656
Copy link
Author

Rover656 commented Nov 9, 2016

@WallyCZ all fixed

@ghost
Copy link

ghost commented Nov 9, 2016

Tested, works nicely.

@Rover656
Copy link
Author

Rover656 commented Nov 9, 2016

@BadiBasso Great. @ST-Apps, it is ready for merge

@ST-Apps ST-Apps added this to the PoGo-UWP 1.1.0 milestone Nov 9, 2016
@ST-Apps ST-Apps merged commit 5de1bbd into ST-Apps:master Nov 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants