I need help completing the installation of the Mirror Credentials APIs from my Python server code. We use the Google Python API library to insert a special authentication token in the Mirror API, but I get an empty result from mirror.accounts (). Insert (). Execute (), where I need to get at least an error or confirmation that the credentials of the API marker are passed to the Google Mirror API.
Here is our Python server code with some version of our secret information, the secret private keys and client_id are in the secret .json file, which we securely store on our server.
with open(os.path.join(os.path.dirname(__file__), 'mirror-credentials.json')) as f: credentials_json = json.load(f) credentials = SignedJwtAssertionCredentials( service_account_name=credentials_json['client_email'], private_key=credentials_json['private_key'], scope='https://www.googleapis.com/auth/glass.thirdpartyauth', ) http = credentials.authorize(httplib2.Http()) mirror = apiclient.discovery.build('mirror', 'v1', http=http) glass_request = mirror.accounts().insert( userToken=$glassware_gallery_user_token, accountType='com.mycompany', accountName="testAccountName", body={ 'features': ["a", "b", "c"], 'password': $myapp_glass_auth_token, 'userData': [{"key": "realName", "value": "Rusty Shackleford"}], 'authTokens': [ {"type": "drchrono_glass_token", "authToken": $myapp_glass_auth_token} ], }, ) retValue = glass_request.execute()
Note. $glassware_gallery_user_token is the token that we transfer from the Google app gallery when we turn on our cookware (we already installed our cookware application).
By executing the above code, we get an empty value for retValue , this is an empty text: {} when printing. From the documentation, it looks like this: this is an error message or confirmation.
In response to the comment:
Here is a listing of what the request we are sending looks like (having received this by inserting print instructions in the httplib2 source code):
body = '{"userData": [{"value": "Rusty Shackleford", "key": "realName"}], "authTokens": [{"authToken": "$ omitted_auth_token", "type": "$ myapp_glass_token "}]," password ":" $ omitted_auth_token "," features ": [" a "," b "," c "]} ',
headers = '{' content-length ':' 305 ',' accept-encoding ':' gzip, deflate ',' accept ':' application / json ',' user-agent ':' google-api-python-client /1.2 (gzip) ',' content-type ':' application / json ',' authorization ':' Bearer ya29.hACi3eQf2L2awk3rrLgf1uZQHen2ZANgT_ObBqTNpqrwC6wa_DwjuO9q '}',
request_uri = '/ mirror / v1 / accounts / $ my_google_serviceid / $ com.myappname / rustyshack? alt = json'
As an answer, I get an empty dictionary: {}
I see that this is actually talking to Googles services for two reasons:
- If I change user_token to invalid, the code throws an exception.
- I see the API call count in the Google Developer Console, counting these attempts as calls against our API quota.
Actual data in the response from Google servers (printed in httplib2 have a status code of 204:
'' / '{' fp ':,' status': 204, 'will_close': False, 'chunk_left': 'UNKNOWN', 'length': 0, 'strict': 0, 'reason': 'No Content' , 'version': 11, 'debuglevel': 0, 'msg':, 'chunked': 0, '_method': 'POST'} '
@TonyAllevato I'm trying to get all the accounts on the device using accountManager.getAccounts (); and I get only one account like "com.google". getAccountsByType ("com.xxxxxx") with my application specified during the browsing process returns an empty array.