Google Apps Marketplace için bir uygulama oluşturduk. Bizim app sadece herkes için yüklüyse çalışır. Ancak sorun şu ki, bazı müşteriler uygulamamızı herkese değil bazı kuruluşlara yükler. Bu müşterilere belirli bir mesaj göstermeyi istiyoruz, ancak sorun, uygulamamızın bazı kuruluşlar için kurulup kurulmadığını veya hiç kurulmamış olduğunu bilmiyoruz. Bu nedenle, bazı kuruluşlar için uygulamamızı yükleyen müşteriler, uygulamamızı hiç yüklemeyen müşterilere yönelik bir mesaj alır. Onlara yükleme düğmesini gösteririz, ancak uygulamayı yüklediklerinde hiçbir şey olmaz, çünkü zaten yüklüdür. Uygulamalarımızın durumunu "herkese açık" olarak nasıl değiştireceğimizi onlara talimat vermek istiyoruz.Uygulamamızın bazı kuruluşlar için yüklü olup olmadığını kontrol edebiliriz, hepsi değil?
Uygulamamızın bazı kuruluşlar için yüklü olup olmadığını nasıl kontrol edebiliriz? Biz Google'dan aşağıdaki hata iletisini alabilirsiniz: Biz hiç bizim app yüklemek vermedi müşterileri için aldığınız hata mesajı olup
Failed to retrieve access token: {
"error" : "unauthorized_client",
"error_description" : "Unauthorized client or scope in request."
}
.
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)
Güncelleme 1: Uygulamalarda> Marketplace uygulamaları bir uygulama kapalı seçilen kuruluşlar veya için üzerinde herkes için üzerinde olabilir
Bu istisna atar Python fonksiyonudur. Uygulamamızın durumunu bilmemiz gerekiyor.
Güncelleme 2: Ben check_general_access
ama bizim uygulama kaldırıldığında da biz (Uygulama genel erişimi vardır) Doğru almak aramayı denedim. Bu, check_access
'un False döndürdüğünü onayladıktan sonra.
@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
Lütfen "bir kuruluş için kurulan" ifadesinin ne anlama geldiğini açıklayınız! –
@KlausD. Lütfen güncellenmiş soruma bakın. – Uri
Güncellemesi bunu netleştirmiyor. – Psytho