相关疑难解决方法(0)

如何在不要求用户复制/粘贴身份验证代码的情况下验证Google云端硬盘?

我正在使用DriveCommandLine应用程序来学习Drive API.我只是想知道是否可以使用Google云端硬盘验证我的桌面应用程序而无需用户从浏览器复制/粘贴授权代码?而只是让一个令牌从浏览器传回给应用程序?我可以使用Dropbox API和Google Documents List API执行此操作,但无法弄清楚如何使用Google Drive API.

谢谢.

Google Drive API - DriveCommandLine示例应用(稍加修改):

public class DriveCommandLine {

  private static String CLIENT_ID = APPCONSTANTS.Google.CONSUMER_KEY;
  private static String CLIENT_SECRET = APPCONSTANTS.Google.CONSUMER_SECRET;

  private static String REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob";

  public static void main(String[] args) throws IOException, URISyntaxException {
    HttpTransport httpTransport = new NetHttpTransport();
    JsonFactory jsonFactory = new JacksonFactory();

    GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
        httpTransport, jsonFactory, CLIENT_ID, CLIENT_SECRET, Arrays.asList(DriveScopes.DRIVE))
        .setAccessType("offline")
        .setApprovalPrompt("force").build();

    String url = flow.newAuthorizationUrl().setRedirectUri(REDIRECT_URI).build();
    System.out.println("Enter authorization code:");
    Desktop.getDesktop().browse(new URI(url));
    BufferedReader br = new …
Run Code Online (Sandbox Code Playgroud)

authentication oauth oauth-2.0 google-drive-api

10
推荐指数
2
解决办法
2万
查看次数