Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we check if our app is installed for some organizations but not all of them?

Tags:

People also ask

How do I track installed apps?

On your Android phone, open the Google Play store app and tap the menu button (three lines). In the menu, tap My apps & games to see a list of apps currently installed on your device. Tap All to see a list of all apps you've downloaded on any device using your Google account.

How do you verify an app?

The settings to activate this feature will vary based on your Android software. If you are using something lower than Android 4.2, go to the settings menu and navigate to Google Settings > Verify App. Go to Settings > Security > Verify apps if you are running Android 4.2 or higher.

How do I block an app from my team?

Sign in to the Teams admin center and access Teams Apps > Permission policies. Select Org-wide app settings. Under Blocked apps, add the apps you want to block across your organization.


We created an application for Google Apps Marketplace. Our app works only if it's installed for everyone. But the problem is, some customers install our app for some organizations, not everyone. We want to display a specific message to those customers, but the problem is that we don't know if our app is installed for some organizations, or not installed at all. Therefore, customers who installed our app for some organizations get a message which is intended for customers who didn't install our app at all. We show them the install button but nothing happens when they install our app again, because it's already installed. We want to give them instructions how to change our app's status to "on for everyone".

How can we check if our app is installed for some organizations? We get the following error message from Google:

Failed to retrieve access token: {   "error" : "unauthorized_client",   "error_description" : "Unauthorized client or scope in request." } 

Which is the same error message we receive for cutomers who didn't install our app at all.

This is the Python function who throws the exception:

  def _do_refresh_request(self, http_request):     """Refresh the access_token using the refresh_token.      Args:       http_request: callable, a callable that matches the method signature of         httplib2.Http.request, used to make the refresh request.      Raises:       AccessTokenRefreshError: When the refresh fails.     """     body = self._generate_refresh_request_body()     headers = self._generate_refresh_request_headers()      logger.info('Refreshing access_token')     resp, content = http_request(         self.token_uri, method='POST', body=body, headers=headers)     if resp.status == 200:       # TODO(jcgregorio) Raise an error if loads fails?       d = simplejson.loads(content)       self.token_response = d       self.access_token = d['access_token']       self.refresh_token = d.get('refresh_token', self.refresh_token)       if 'expires_in' in d:         self.token_expiry = datetime.timedelta(             seconds=int(d['expires_in'])) + datetime.datetime.utcnow()       else:         self.token_expiry = None       if self.store:         self.store.locked_put(self)     else:       # An {'error':...} response body means the token is expired or revoked,       # so we flag the credentials as such.       logger.info('Failed to retrieve access token: %s' % content)       error_msg = 'Invalid response %s.' % resp['status']       try:         d = simplejson.loads(content)         if 'error' in d:           error_msg = d['error']           self.invalid = True           if self.store:             self.store.locked_put(self)       except StandardError:         pass       raise AccessTokenRefreshError(error_msg) 

Update 1: in Apps > Marketplace apps, an app can be on for everyone, on for selected orgs or off. We need to know the status of our app.

in Apps > Marketplace apps

Update 2: I tried calling check_general_access but also when our application is uninstalled we receive True (Application has general access). This is after we confirmed that check_access returned False.

@staticmethod def check_access(admin_email):     http = httplib2.Http()     credentials = SignedJwtAssertionCredentials(         SERVICE_EMAIL,          PRIVATE_KEY,          scope='https://apps-apis.google.com/a/feeds/emailsettings/2.0/ https://www.googleapis.com/auth/admin.directory.user.readonly',          sub=str(admin_email),     )     http = credentials.authorize(http)     try:         service = build(serviceName='admin', version='directory_v1', http=http)         logging.info("Application has access to admin's %s domain" % (admin_email))         return True     except Exception as e:         logging.info("Application does not have access to admin's %s domain (exception: %s)" % (admin_email, e.message))         return False  @staticmethod def check_general_access():     http = httplib2.Http()     credentials = SignedJwtAssertionCredentials(         SERVICE_EMAIL,         PRIVATE_KEY,         scope='https://apps-apis.google.com/a/feeds/emailsettings/2.0/ https://www.googleapis.com/auth/admin.directory.user.readonly',     )     http = credentials.authorize(http)     try:         service = build(serviceName='admin', version='directory_v1', http=http)         logging.info("Application has general access")         return True     except Exception as e:         logging.info("Application does not have general access (exception: %s)" % e.message)         return False