0
返回Android Android中的「訪問未配置」,我嘗試使用Google IO 2013代碼示例,特別是SocialStreamFragment,以基於標籤搜索顯示Google Plus帖子。檢索Google+活動使用GoogleIO13示例應用程序代碼
步驟來完成:
- 綜合SocialStreamFragment.java類及相關clasees等,在我的項目。
- 在控制檯API,我已經啓用了Google+ API爲我的項目
- 在控制檯API我生成Android應用一個簡單的API訪問鍵,配置我的應用程序的封裝和調試/ PROD鍵所允許的應用程序。
- 我將簡單訪問密鑰複製爲Config.API_KEY。
但是,獲取活動/帖子的代碼失敗,IOException:403,「Access Not Configured」。
public List<Activity> loadInBackground() {
mIsLoading = true;
// Set up the HTTP transport and JSON factory
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new GsonFactory();
// Set up the main Google+ class
Plus plus = new Plus.Builder(httpTransport, jsonFactory, null)
.setApplicationName(NetUtils.getUserAgent(getContext()))
.setGoogleClientRequestInitializer(
new CommonGoogleClientRequestInitializer(Config.API_KEY))
.build();
ActivityFeed activities = null;
try {
activities = plus.activities().search(mSearchString)
.setPageToken(mNextPageToken)
.setOrderBy("recent")
.setMaxResults(MAX_RESULTS_PER_REQUEST)
.setFields(PLUS_RESULT_FIELDS)
.execute();
mHasError = false;
mNextPageToken = activities.getNextPageToken();
} catch (IOException e) {
e.printStackTrace();
mHasError = true;
mNextPageToken = null;The
}
return (activities != null) ? activities.getItems() : null;
}
我在想什麼或做錯了什麼?
我的項目還在API Console中爲已安裝的應用程序配置了客戶端ID。這可能是一個問題嗎?