हमने Google Apps Marketplace के लिए एक एप्लिकेशन बनाया है। हमारा ऐप केवल तभी काम करता है जब यह हर किसी के लिए स्थापित हो। लेकिन समस्या यह है कि कुछ ग्राहक कुछ संगठनों के लिए अपना ऐप इंस्टॉल करते हैं, हर किसी के लिए नहीं। हम उन ग्राहकों को एक विशिष्ट संदेश प्रदर्शित करना चाहते हैं, लेकिन समस्या यह है कि हम नहीं जानते कि हमारे संगठन कुछ संगठनों के लिए स्थापित है या नहीं, बिल्कुल स्थापित नहीं है। इसलिए, कुछ संगठनों के लिए हमारे ऐप को इंस्टॉल करने वाले ग्राहक एक संदेश प्राप्त करते हैं जिसका उद्देश्य उन ग्राहकों के लिए है जिन्होंने हमारे ऐप को इंस्टॉल नहीं किया है। हम उन्हें इंस्टॉल बटन दिखाते हैं लेकिन कुछ भी तब नहीं होता जब वे हमारे ऐप को दोबारा इंस्टॉल करते हैं, क्योंकि यह पहले से इंस्टॉल हो चुका है। हम उन्हें निर्देश देना चाहते हैं कि हमारे ऐप की स्थिति को "हर किसी के लिए" कैसे बदलें।हम कैसे जांच सकते हैं कि हमारे संगठन कुछ संगठनों के लिए स्थापित है या नहीं, लेकिन उनमें से सभी नहीं?
हम कैसे जांच सकते हैं कि कुछ संगठनों के लिए हमारा ऐप इंस्टॉल किया गया है या नहीं? हम गूगल से निम्न त्रुटि संदेश मिलता है:
Failed to retrieve access token: {
"error" : "unauthorized_client",
"error_description" : "Unauthorized client or scope in request."
}
कौन सा एक ही त्रुटि संदेश हम cutomers जो बिल्कुल हमारे एप्लिकेशन इंस्टॉल नहीं हुआ के लिए प्राप्त करते हैं।
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)
अद्यतन: 1: Apps में> बाज़ार क्षुधा, कोई एप्लिकेशन, हर किसी के लिए पर हो सकता है चयनित संगठनों या बंद करने के लिए पर
यह अजगर समारोह जो अपवाद फेंकता है। हमें अपने ऐप की स्थिति जानने की जरूरत है।
अद्यतन 2: मैं check_general_access
लेकिन यह भी जब हमारे एप्लिकेशन अनइंस्टॉल हो हम यह सच है (अनुप्रयोग सामान्य पहुंच सकता है) प्राप्त बुला की कोशिश की। यह पुष्टि करने के बाद कि check_access
गलत हो गया।
@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
विवरण में बताएं कि "किसी संगठन के लिए इंस्टॉल" का अर्थ क्या है! –
@ क्लोस डी। कृपया मेरा अद्यतन प्रश्न देखें। – Uri
अद्यतन यह कोई स्पष्ट नहीं करता है। – Psytho