当我尝试连接到 strava 时遇到问题。我不知道在授权回调域中放置什么。我放置了 localhost 或 127.0.0.1
这是代码:
public class MainActivity extends AppCompatActivity {
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
private static final int RQ_LOGIN = 1001;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StravaLoginButton loginButton = (StravaLoginButton) findViewById(R.id.login_button);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
login();
}
});
}
private void login() {
Intent intent = StravaLogin.withContext(this)
.withClientID(29519)
.withRedirectURI("gekon.technologypark.cz")
.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();
}
}
}
我已经看到 redirectUri 必须与回调域相同,所以我输入了localhost或127.0.0.1但我仍然收到此错误