android - 如何从我的 Android 应用程序访问谷歌课堂 API
问题描述
我正在尝试制作一个 android 应用程序,在用户登录后从用户的谷歌课堂帐户(课程、家庭作业等)中获取信息。
感谢教程:开始将 Google 登录集成到您的 Android 应用程序中,用户可以登录,但现在我想知道如何从他的登录帐户获取 google 课堂服务。
我已经请求了必要的范围(ClassroomScopes.CLASSROOM_COURSES)
,这是我一直在使用的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
//google sign in stuff
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(new Scope(ClassroomScopes.CLASSROOM_COURSES))
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
//will return GoogleSignInAccount if user already signed in before
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
}
public void loadClassroomAndroid(View v){
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
// The Task returned from this call is always completed, no need to attach
// a listener.
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
GoogleSignInAccount account = task.getResult(Exception.class);
//How can I get a Classroom object from this account ?
//Or at least get a user's classroom info ?
}
}
解决方案
推荐阅读
- vb.net - 查看对象时VS 2015 VB调试崩溃
- python - 我怎样才能用一个多字段来做一个跟随系统?
- java - 为什么不相关的网络活动会提高慢环回性能?
- javascript - 使用字典过滤 javascript 数据对象
- javascript - 发布到网络时未提供 Google 电子表格 ID
- javascript - 未捕获的引用错误:表单未在 loadEventListeners 中定义
- python - 努力让 Sum() 函数从列表中输出一个值
- javascript - 使用 JS 的复选框和过滤项目
- mysql - AngularJS 指令无法检查 null
- javascript - 无法在 D3 中移动 svg 元素