import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Collections;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.services.drive.DriveScopes;
public class pred {
public static String getGoogleAccessToken(String jsonKeyFilePath)
throws FileNotFoundException, IOException, GeneralSecurityException {
GoogleCredential credential = GoogleCredential.fromStream(
new FileInputStream(jsonKeyFilePath)).createScoped(
Collections.singleton(DriveScopes.DRIVE));
credential.refreshToken();
return credential.getAccessToken();
}
public static void main(String[] args) throws IOException, GeneralSecurityException {
String a=getGoogleAccessToken("D:ml-latest-small\\untitled\\src\\woven*************.json");
System.out.println(a);
}
}
我想获取访问令牌以从Google云端中部署的版本中获取预测。上面的代码 提供对Google云端硬盘的访问令牌。有没有办法更改此部分(DriveScopes.DRIVE)以获取 Google云端访问令牌。或者还有另一种从Java获取访问令牌的方法。