我对 Strava API 有点混乱,但是当我想执行初始身份验证时,我总是收到 404 错误。我对此很陌生,所以任何帮助将不胜感激。
@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();
}
});