SweetzpotAS / StravaZpot-Android

A fluent API to integrate with Strava on Android apps
70 stars 36 forks source link

What to put in redirect uri and CODE #21

Closed AlexKolydas closed 6 years ago

AlexKolydas commented 6 years ago

Hello.I would like you to help me with the redirect uri.I put the same url that i put in the domain callback in stravas page(which is localhost). but i get this error.Can you please help by telling me which url to put?Also the .withCode(CODE) what should i write?Sorry for this but i'm totally new

untitled
truizlop commented 6 years ago

It would be helpful if you write the code you are using right now, otherwise the only thing I can do is refer you to the documentation, where everything is clearly explained, including the question you are asking about the withCode(CODE) method.

AlexKolydas commented 6 years ago
 private void login() {
        Intent intent = StravaLogin.withContext(this)
                                    .withClientID(29519)
                                    .withRedirectURI("strava.com")
                                    .withApprovalPrompt(AUTO)
                                    .withAccessScope(AccessScope.VIEW_PRIVATE_WRITE)
                                    .makeIntent();
        startActivityForResult(intent, RQ_LOGIN);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(requestCode == RQ_LOGIN && resultCode == RESULT_OK && data != null) {
            Log.d("Strava code", data.getStringExtra(RESULT_CODE));
            AuthenticationConfig config = AuthenticationConfig.create()
                    .debug()
                    .build();
            AuthenticationAPI api = new AuthenticationAPI(config);
            LoginResult result = api.getTokenForApp(AppCredentials.with(29519, "8d55af50a97a9f4b5269670de00bf5e6f4b9942d "))
                    .withCode(RESULT_CODE)
                    .execute();
        }
    }

This is the code i haven't changed anything i believe
AlexKolydas commented 6 years ago

I haven't changed any of your code.I just want to understand what to put in the redirecturi and CODE

On Mon, 22 Oct 2018, 14:28 Tomás Ruiz-López, notifications@github.com wrote:

It would be helpful if you write the code you are using right now, otherwise the only thing I can do is refer you to the documentation, where everything is clearly explained, including the question you are asking about the withCode(CODE) method.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/SweetzpotAS/StravaZpot-Android/issues/21#issuecomment-431820666, or mute the thread https://github.com/notifications/unsubscribe-auth/Ajpi4zv0_DfvXiikhXWpo1H-OArPnGRoks5unbn6gaJpZM4XzL-e .

truizlop commented 6 years ago

Referring to the documentation in the README:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if(requestCode == RQ_LOGIN && resultCode == RESULT_OK && data != null) {
        String code = data.getStringExtra(StravaLoginActivity.RESULT_CODE);
        // Use code to obtain token
    }
}

In any case, you also have an example folder here.

AlexKolydas commented 6 years ago

i think i manage to do something!Thank you very much!