2013-03-13 121 views
0

我试图使用Oauth2进行身份验证。我早期的实现用OAuth2Draft10但由于它现在已经过时了,所以我想移动到OAuth2.0的http://www.proksi.us/browse.php?u=Oi8vY29kZS5nb29nbGUuY29tL3AvZ29vZ2xlLWFwaS1qYXZhLWNsaWVudC93aWtpL09BdXRoMg%3D%3D&b=143Oauth2.0身份验证Google Adsense

煤矿是安装的应用程序和我下面http://www.proksi.us/browse.php?u=Oi8vY29kZS5nb29nbGUuY29tL3AvZ29vZ2xlLWFwaS1qYXZhLWNsaWVudC93aWtpL09BdXRoMg%3D%3D&b=143#Installed_Applications

,但面临的问题,同时调用授权()方法在这里,无法通过VerificationCodeReceiver。

任何帮助或任何指导,我可以通过哪里我错了或失踪.. ..?

回答

0

解决.. :)

不需要VerificationCodeReceiver。

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"); 
     } 

谢谢.. :)

+0

你从哪儿弄来adsense.json文件? – user12384512 2013-04-13 10:29:12

+0

adsense.json是我们持续访问令牌和刷新令牌的地方。 – Javatech 2013-04-18 08:05:30