当我尝试连接到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 ,但我仍然遇到此错误
答案 0 :(得分:0)
您必须在http://
参数中包含redirect_uri
;例如如果您将localhost
设置为回调域:
https://www.strava.com/oauth/authorize?
client_id=XXXXX&
redirect_uri=http://localhost&
response_type=code&
scope=read_all,profile:read_all,activity:read_all