0

我正在尝试使用 Google 的 Beacon Proximity api。我已按照以下步骤整合它们:

1) Signed up on Google Api Console.
2) Created new Project.
3) enabled Beacon proximity api and Nearby Api.
4) Generated Api key from Credentials. 

之后我调用以下api:

 {
  "advertisedId": {
    "type": "EDDYSTONE",
    "id": "ABEiM0RVZneImaq7zN3u/w=="
  },
  "status": "ACTIVE",
  "placeId": "ChIJL_P_CXMEDTkRw0ZdG-0GVvw",
  "latLng": {
    "latitude": "71.6693771",
    "longitude": "-22.1966037"
  },
  "indoorLevel": {
    "name": "1"
  },
  "expectedStability": "STABLE",
  "description": "An example beacon.",
  "properties": {
    "position": "entryway"
  }
}

使用以下网址:

https://proximitybeacon.googleapis.com/v1beta1/beacons:register?key=xxxx(my_api_key)

但回复说:

{
  "error": {
    "code": 403,
    "message": "Unauthorized.",
    "status": "PERMISSION_DENIED"
  }
}

我错过了什么..

I also tried to use Beacon tools app but after entering EID and all other credentials..the App crashes(on android), while it is not able to connect to my eddystone on Ios. 
4

2 回答 2

1

找到解决方案,API_KEY 只能用于访问已经注册的信标及其特征,而注册和更新我们需要 ClientId 和客户端密钥,您可以在 OAuth2.0 Playground 中注册。它对我有用;)

于 2016-09-12T21:54:26.023 回答
0

您可以在 google API 控制台上创建帐户服务密钥后获取服务令牌。然后使用以下代码生成它:

String token = null;

try{
    GoogleCredential credential = GoogleCredential.fromStream(accesKey).createScoped
                    (Collections.singleton("https://www.googleapis.com/auth/userlocation.beacon.registry"));


    credential.refreshToken();
    token = credential.getAccessToken();

} catch (FileNotFoundException ex) {
        Logger.getLogger(BeaconRegisterClass.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
        Logger.getLogger(BeaconRegisterClass.class.getName()).log(Level.SEVERE, null, ex);
}

然后把它放在你的电话标题上:

key: Authorization value: Bearer (your token here)

将此调用的主体设置为 beacon.json

于 2018-02-11T22:35:22.563 回答