0

我正在尝试使用 Oauth2 进行身份验证。我早期的实现是使用 OAuth2Draft10 但由于它现在已弃用,所以我想转移到 OAuth2.0 http://www.proksi.us/browse.php?u=Oi8vY29kZS5nb29nbGUuY29tL3AvZ29vZ2xlLWFwaS1qYXZhLWNsaWVudC93aWtpL09BdXRoMg%3D%3D&b=1

我的是一个已安装的应用程序,我正在关注http://www.proksi.us/browse.php?u=Oi8vY29kZS5nb29nbGUuY29tL3AvZ29vZ2xlLWFwaS1qYXZhLWNsaWVudC93aWtpL09BdXRoMg%3D%3D&b=143#Installed_Applications

但是在这里调用 authorize() 方法时遇到问题,无法通过 VerificationCodeReceiver。

任何帮助或任何指南,我可以从中找到错误或失踪的地方..?

4

1 回答 1

0

解决 ..:)

无需验证码接收器。

 public static Credential authorize() throws Exception {
        // load client secrets
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(
            JSON_FACTORY, AdSenseSample.class.getResourceAsStream("/client_secrets.json"));


        // set up file credential store
        File jsonFile = new File("/adsense.json"); 

        FileCredentialStore credentialStore = new FileCredentialStore(jsonFile, JSON_FACTORY);

        // set up authorization code flow
        GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
            HTTP_TRANSPORT, JSON_FACTORY, clientSecrets,
            Collections.singleton(AdSenseScopes.ADSENSE_READONLY)).setCredentialStore(
            credentialStore).build();
        // authorize
        return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
      }

谢谢..:)

于 2013-03-14T06:27:02.993 回答