【发布时间】:2019-08-30 01:30:33
【问题描述】:
我想获得 Youtube 标题和其他。
我遵循this question 中的描述。
我在这里做什么: 我使用改造来请求数据。
这是我的服务:
@GET("https://www.googleapis.com/youtube/v3/videos?key=" + C.googlDevApiKey +"&part=snippet,contentDetails,statistics,status")
Call<JsonObject> getYoutubeInfo(
@Query("video_id") String videoId
);
它正在执行请求:
Api.getClient(context)
.create(Service.class)
.getYoutubeInfo("v=r2qd_KPQiZE&t=31s")
.enqueue(new Callback<JsonObject>() {
@Override
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
if (response.isSuccessful()){
Log.e("TAG", "youtube Response getYoutubeInfo: " + response.body().toString());
} else {
Log.e("TAG", "youtube Response getYoutubeInfo: error: " + response.code());
}
}
@Override
public void onFailure(Call<JsonObject> call, Throwable t) {
}
});
和日志拦截器:
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: vary: Origin
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: vary: X-Origin
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: content-type: application/json; charset=UTF-8
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: date: Fri, 30 Aug 2019 00:32:23 GMT
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: expires: Fri, 30 Aug 2019 00:32:23 GMT
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: cache-control: private, max-age=0
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: x-content-type-options: nosniff
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: x-frame-options: SAMEORIGIN
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: x-xss-protection: 1; mode=block
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: server: GSE
2019-08-30 07:32:23.679 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: alt-svc: quic=":443"; ma=2592000; v="46,43,39"
2019-08-30 07:32:23.680 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: {
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "error": {
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "errors": [
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: {
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "domain": "usageLimits",
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "reason": "ipRefererBlocked",
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "message": "The request did not specify any Android package name or signing-certificate fingerprint. Please ensure that the client is sending them or use the API Console to update your key restrictions.",
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "extendedHelp": "https://console.developers.google.com/apis/credentials?project=XXXXXXX"
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: }
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: ],
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "code": 403,
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: "message": "The request did not specify any Android package name or signing-certificate fingerprint. Please ensure that the client is sending them or use the API Console to update your key restrictions."
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: }
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: }
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: <-- END HTTP (639-byte body)
2019-08-30 07:32:23.681 1683-1760/id.lkmsbwm.bwmmobile.dev D/OkHttp: <-- 403 https://www.googleapis.com/youtube/v3/videos?key=AIzaSyCd71dtBE9gQhALXOOGo6krGT9F8A7IHJM&part=snippet,contentDetails,statistics,status&video_id=v%3Dr2qd_KPQiZE%26t%3D31s (256ms)
我在控制台中设置了限制使用您的 Android 应用程序。
如何解决
【问题讨论】: