我需要使用Google Play游戏服务API在Dart中开发WebClient。当我在Dartium中运行它时,以下源会引发异常。 这里的问题是什么?
例外:
拒绝设置不安全标头" user-agent"拒绝设置不安全的标题 "内容长度"无法加载资源:服务器响应了 状态401(未经授权)
https://www.googleapis.com/games/v1/leaderboards/XXXXXX?alt=json 例外:未捕获错误:访问被拒绝(www-authenticate标头 是:Bearer realm =" https://accounts.google.com/AuthSubRequest", 误差= INVALID_TOKEN)。
import 'dart:html';
import 'package:googleapis_auth/auth_browser.dart';
import 'package:googleapis/games/v1.dart';
void main() {
var id = new ClientId("xxxxxxxx.apps.googleusercontent.com", "xxxx");
var scopes = [GamesApi.PlusLoginScope, GamesApi.GamesScope];
// Initialize the browser oauth2 flow functionality.
createImplicitBrowserFlow(id, scopes).then((BrowserOAuth2Flow flow) {
flow.clientViaUserConsent().then((AuthClient client) {
// Authenticated and auto refreshing client is avaliable in [client].
var game = new GamesApi(client);
game.leaderboards.get("XXXXXX").then( (Leaderboard leaderBoard) {
print(leaderBoard.id);
});
/* game.leaderboards.list().then((onValue) {
print(onValue);
});*/
client.close();
flow.close();
});
});
}