Java 授权代码已安装App
我正在尝试使用我运行的google drive.apiJava 授权代码已安装App,java,google-api,google-drive-api,google-oauth,google-api-java-client,Java,Google Api,Google Drive Api,Google Oauth,Google Api Java Client,我正在尝试使用我运行的google drive.api private static Credential authorize() throws Exception { // load client secrets InputStream in = new FileInputStream("C:\\Users\\orion\\OneDrive\\Documents\\GitHub\\teachervoiceorganization\\JavaProject\\cl
private static Credential authorize() throws Exception {
// load client secrets
InputStream in = new FileInputStream("C:\\Users\\orion\\OneDrive\\Documents\\GitHub\\teachervoiceorganization\\JavaProject\\client_id.json");
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY,
new InputStreamReader(in));
if (clientSecrets.getDetails().getClientId().startsWith("515427348790")
|| clientSecrets.getDetails().getClientSecret().startsWith("i50nkSMoqVegC0UdkD1W8g3Y")) {
System.out.println(
"Enter Client ID and Secret from https://code.google.com/apis/console/?api=drive "
+ "into drive-cmdline-sample/src/main/resources/client_secrets.json");
}
// set up authorization code flow
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, JSON_FACTORY, clientSecrets,
Collections.singleton(DriveScopes.DRIVE_FILE)).setDataStoreFactory(dataStoreFactory)
.build();
// authorize
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
}
我理解你的问题
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
用户id位于何处?我已经看过了,没有运气。任何东西都会有帮助。谷歌用户ID被编码为JWT的
子
,该JWT是通过调用身份验证代码交换令牌返回的。您使用的Java客户机库混淆了所有内容,因此JWT令牌暴露在何处是任何人的猜测。我个人的建议是丢弃库,直接调用两个OAuth URL。
这些步骤是:-
注意,您需要包括
电子邮件范围以及相应的驱动器范围。您的问题不清楚您指的是什么用户id?