2016-09-12 5 views
0

Googleのビーコン近接APIを使用しようとしています。私はそれらを統合するには、次の手順に従っていますGoogleプロキシミティビーコンAPIが不正なエラー403を返します

その後
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呼び出し:follwing URLを

{ 
    "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. 
+0

beacon.jsonあなたはあなたの実際のAPIを使用しなかったとして

key: Authorization value: Bearer (your token here) 

は、この呼び出しのボディを設定URLの最後にキーがありますか? –

+0

はい(私は実際の値を使用しました)私はここでそれをトリミングしました..それ以外の場合、無効なApi_keyエラー –

答えて

0

は、登録および更新しながら、私たちがClientIdを、クライアントの秘密鍵を必要とし、あなたがのOAuth2に登録することができ、API_KEYのみアクセス既に登録ビーコンとその特徴に使用することができ、解決策を見つけました.0遊び場。 私のために働いた)

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); 
} 

次に、あなたの呼び出しのヘッダーの上に置く:

関連する問題