2013-03-13 152 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