0
有一點特殊之處,嘗試創建try catch代碼片段來處理GoogleTokenResponse,並且編譯器在嘗試時拋出異常錯誤。有任何想法嗎?grails:嘗試拋出意外的令牌:嘗試:
錯誤消息:
| Loading Grails 2.2.4
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application....
| Compiling 1 source files.
| Error Compilation error: startup failed:
/Users/bengtbjorkberg/Documents/grails-work/iCRM/grails-app/services/icrm/GlAuthService.groovy: 44: unexpected token: try @ line 44, column 3.
try {
^
1 error
和有關
def setCredentila()
HttpTransport transport = new NetHttpTransport()
JacksonFactory jsonFactory = new JacksonFactory()
String clientId = grailsApplication.config.googleId.glAppsId
String clientSecret = grailsApplication.config.googleId.clientSecret
String redirectUrl = grailsApplication.config.googleUrl.redirectURL
try {
GoogleTokenResponse response = new GoogleAuthorizationCodeTokenRequest(transport, jsonFactory, clientId, clientSecret,session.code, redirectUrl).execute()
} catch (GoogleTokenResponseException e) {
if (e.getDetails() != mull){
log.error e.getDetails().getError()
if (e.getDetails().getErrorDescription() != null) {
log.error e.getDetails().getErrorDescription()
}
if (e.getDetails().getErrorUri() != null) {
log.error e.getDetails().getErrorUri()
}
} else {
log.error e.getMessage()
}
}
}
GoogleCredential accessToken = new GoogleCredential.Builder().setClientSecrets(clientId, clientSecret).setJsonFactory(jsonFactory).setTransport(transport).build().setAccessToken(response.getAccessToken()).setRefreshToken(response.getRefreshToken());
session.accessToken = accessToken
}
也許一個錯字,但'高清setCredentila()'應該是'高清setCredentila(){' – Grooveek
這是一個錯字,但那裏有另外兩個問題,以及:)首先是它TokenResponseException不GoogleTokenResponseException ,或者至少我覺得這樣還不能令人滿意。其次是我在方括號數中輸了很多 – vrghost
所以...現在可以嗎?你能更新你的代碼,並告訴現在有什麼問題嗎? – Grooveek