我正在尝试使用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"
}
}使用下面的url:
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. 发布于 2016-09-13 05:54:26
找到了解决方案,API_KEY只能用于访问已经注册的信标及其特征,而注册和更新我们需要ClientId和客户端密钥,您可以在OAuth2.0Playground中注册它。它对我很有效;)
发布于 2018-02-12 06:35:23
您可以在google API控制台创建账号服务密钥后获取服务token。然后用下面的代码生成它:
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
https://stackoverflow.com/questions/39451979
复制相似问题