मैं उपयोगकर्ता 0 डी लाने के लिए इस course से एक (थोड़ा संशोधित) वर्कअराउंड का उपयोग कर रहा हूं, जो एंड्रॉइड क्लाइंट से अनुरोध भेजा गया था, जो शून्य है।Google ऐप इंजन क्लाउड एंडपॉइंट्स उपयोगकर्ता आईडी शून्य है
/**
* This is an ugly workaround for null userId for Android clients.
*
* @param user A User object injected by the cloud endpoints.
* @return the App Engine userId for the user.
*/
private static String getUserId(User user) {
String userId = user.getUserId();
if (userId == null) {
LOG.info("userId is null, so trying to obtain it from the datastore.");
AppEngineUser appEngineUser = new AppEngineUser(user);
ofy().save().entity(appEngineUser).now();
AppEngineUser savedUser = ofy().load().key(appEngineUser.getKey()).now();
userId = savedUser.getUser().getUserId();
LOG.info("Obtained the userId: " + userId);
}
return userId;
}
हालांकि मैं उपयोगकर्ता आईडी प्राप्त करने में सक्षम नहीं हूं।
INFO: Obtained the userId: null
यह कामकाज पहले से ही अन्य परियोजनाओं में पूरी तरह से काम कर चुका है, इसलिए समस्या कहीं और होनी चाहिए। मेरे अंतिम बिंदु API निम्नलिखित स्कोप, clientIds और दर्शकों के साथ टिप्पणी की जाती है:
scopes = {
Constants.EMAIL_SCOPE
},
clientIds = {
Constants.API_EXPLORER_CLIENT_ID,
Constants.WEB_CLIENT_ID,
Constants.ANDROID_CLIENT_ID
},
audiences = {
Constants.ANDROID_AUDIENCE
}
Constants.ANDROID_AUDIENCE
और Constants.WEB_CLIENT_ID
ही हैं। मैं एक वेब क्लाइंट आईडी जोड़ने के लिए वेब क्लाइंट का उपयोग नहीं कर रहा हूं, लेकिन Google told me का उपयोग नहीं कर रहा हूं। क्या इस क्लाइंट आईडी को यूरिस और जावास्क्रिप्ट उत्पत्ति को निर्दिष्ट करने की आवश्यकता है?
मेरे एंड्रॉइड क्लाइंट में मैं दर्शकों को निर्दिष्ट करने के लिए निम्न का उपयोग कर रहा हूं।
mCredential = GoogleAccountCredential.usingAudience(
EndpointService.this,
"server:client_id:IDIDIDID.apps.googleusercontent.com"
);
कृपया इसे एक को समझने में मेरी सहायता करें।
Google एंडपॉइंट भेजता है जो एंडपॉइंट पर बनाया गया है, इसका मतलब है, उपयोगकर्ता आईडी पहले एंड्रॉइड पर Google एंडपॉइंट पर सेट नहीं कर रहा है। –
क्षमा करें, मुझे समझ में नहीं आता है। – raptor