Невозможно отправить оценку в таблицу лидеров с помощью плагина google_sign_in в Flutter - PullRequest
0 голосов
/ 30 апреля 2019

Мне больно получить доступ к игровому сервису.

Я создаю таблицу лидеров и в соответствии с Результаты: список Я делаю

GET https://www.googleapis.com/games/v1/leaderboards/$LEADERBOARD_ID/scores/PUBLIC?timeSpan=ALL_TIME

Возвращает

{
  kind: games#leaderboardScores, 
  numScores: 0
} 

кажется нормальным, и после этого я хочу отправить счет, поэтому в соответствии с Счета: отправить Я делаю

POST https://www.googleapis.com/games/v1/leaderboards/$LEADERBOARD_ID/scores?score=$score

, но ответ

code: 401, message: There is no linked app associated with this client ID.

Я связал, повторно связал, повторно связал приложение в Play Console, но оно не работает вообще, такая же проблема также появляется при Scores: get

GET https://www.googleapis.com/games/v1/players/$id/leaderboards/$LEADERBOARD_ID/scores/ALL_TIME

Если кто-то знает, как решить эту проблему, я ценю вашу помощь.

Кстати, вот мой код:

import 'dart:convert';
import "package:http/http.dart" as http;
import 'package:google_sign_in/google_sign_in.dart';
import 'package:BallPhobia/playgames.dart';  
class PlayServices {
  static const LEADERBOARD_ID='MY_LEADERBOARD_ID';
  static final GoogleSignIn _googleSignIn = GoogleSignIn(signInOption: SignInOption.games,scopes: ['https://www.googleapis.com/auth/games']);
  static GoogleSignInAccount account;
  static Map<String, dynamic> userData;
  static Future singIn() async { 
      account = await _googleSignIn.signIn(); 
      final http.Response response = await http.get(
        'https://www.googleapis.com/games/v1/players/me',
        headers: await account.authHeaders,
      );
      userData = json.decode(response.body);
      print(userData);
  }

  static Future<ScoreResults> loadScores() async {
    final http.Response response = await http.get(
      'https://www.googleapis.com/games/v1/leaderboards/$LEADERBOARD_ID/scores/PUBLIC?timeSpan=ALL_TIME',
      headers: await account.authHeaders,
    );
    final Map<String, dynamic> data = json.decode(response.body); 
    print(data); 
  }

  // returns code: 401, message: There is no linked app associated with this client ID.
  static Future<ScoreResults> loadMyScores() async { 
  final id = userData['playerId'] ;
  final http.Response response = await http.get(
    'https://www.googleapis.com/games/v1/players/$id/leaderboards/$LEADERBOARD_ID/scores/ALL_TIME',
      headers: await account.authHeaders,
    );
    final Map<String, dynamic> data = json.decode(response.body);
    print(data); 
  }

 // returns code: 401, message: There is no linked app associated with this client ID.
  static Future writeScore(int score) async {  
    final http.Response response = await http.post(
      'https://www.googleapis.com/games/v1/leaderboards/$LEADERBOARD_ID/scores?score=$score',
      headers: await account.authHeaders,
    );
    final Map<String, dynamic> data = json.decode(response.body);
    print(data);
  }
}
...