我在清单文件中添加了这段代码:
<data android:scheme="https"
android:host="strava"/>
然后调用隐式意图在 strava 中进行授权,如下所示:
btnConnect.setOnClickListener {
val intentUri = Uri.parse("https://www.strava.com/oauth/mobile/authorize")
.buildUpon()
.appendQueryParameter("client_id", "CLIENT_ID")
.appendQueryParameter("response_type", "code")
.appendQueryParameter("approval_prompt", "auto")
.appendQueryParameter("scope", "activity:read_all")
.build()
val intent = Intent(Intent.ACTION_VIEW, intentUri)
startActivity(intent)
}
但是在浏览器中出现这样的错误:
{"message":"Bad Request", "errors":[{"resource":"Application", "field":"redirect_url", "code":"invalid"}]}