我想在课堂apis中集成oauth id,我从google api console下载client_secret.json用于创建android应用程序, 以前我正在通过基于电子邮件的凭据,现在我想在不询问电子邮件的情况下更改为oauth id。
这是我的代码:但这个代码我从谷歌教室apis使用java,但它不能在android.Please有人帮助我。
InputStream in =
Sample1.class.getResourceAsStream("/client_secret.json");
GoogleClientSecrets clientSecrets =
null;
try {
clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
} catch (IOException e) {
e.printStackTrace();
}
GoogleAuthorizationCodeFlow flow =
null;
flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, Arrays.asList(SCOPES))
.setAccessType("offline")
.build();
try {
credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
} catch (IOException e) {
e.printStackTrace();
}
但实际上是访问谷歌教室的原始网址 的API: https://www.googleapis.com/auth/classroom.courses.readonly