Search code examples
javaandroidoauth-2.0strava

Strava API returning 404 at intitial authentication


i am messing a bit with the Strava API, but when i want to perfrom the initial authentication, i always receive a 404 error. I am rather new to this, so any help would be very appreciated.

            @Override
            public void onClick(View v) {
                RequestQueue queue = Volley.newRequestQueue(MainActivity.this);

                final Uri testUri = Uri.parse("https://www.strava.com/oauth/token")
                        .buildUpon()
                        .appendQueryParameter("client_id", client_id)
                        .appendQueryParameter("client_secret", client_secret)
                        .appendQueryParameter("code", token)
                        .appendQueryParameter("grant_type", "authorization_code")
                        .build();

                StringRequest stringRequest = new StringRequest(Request.Method.GET, testUri.toString(),
                        new Response.Listener<String>() {
                            @Override
                            public void onResponse(String response) {
                                Toast.makeText(MainActivity.this,"Response received", Toast.LENGTH_SHORT).show();
                                textview.setText(response);
                            }
                        }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        error.getCause();
                        Toast.makeText(MainActivity.this,"Error received", Toast.LENGTH_SHORT).show();
                    }
                });

                queue.add(stringRequest);
                Toast.makeText(MainActivity.this,"Request sent", Toast.LENGTH_SHORT).show();
            }
        });

Solution

  • Well, this is awkward. I was using the GET-method, while it should have been a POST method. After correcting this, my problem was resolved.