grails アプリで Spring Security Facebook プラグインを使用しています。認証後にFacebookページから戻ると、以下のエラーメッセージが表示されます。Facebook ユーザーの詳細はデータベースに保存されません。このエラーを解決し、Facebook ユーザーを正常に認証するのを手伝ってください。前もって感謝します。
FacebookUser.groovy ドメイン クラス
class FacebookUser {
long uid
String accessToken
Date accessTokenExpires
static belongsTo = [user: User]
static constraints = {
uid unique: true
}
}
spring-security-facebook アプリの Config.groovy 設定
grails.plugins.springsecurity.facebook.domain.classname='com.awnsys.gcx.FacebookUser'
grails.plugins.springsecurity.facebook.domain.appUserConnectionPropertyName = 'user'
grails.plugins.springsecurity.facebook.appId='APPID'
grails.plugins.springsecurity.facebook.secret='secretID'
grails.plugins.springsecurity.facebook.autoCreate.enabled=true
grails.plugins.springsecurity.facebook.autoCreate.roles=['ROLE_USER', 'ROLE_FACEBOOK',]
以下は、ユーザーが Facebook でアプリを受け入れた後、Facebook からリダイレクトするときにブラウザーに表示されるエラー メッセージです。
Error 500: Internal Server Error
URI : /myapp/j_spring_security_facebook_check
Class : grails.validation.ValidationException
Message : Validation Error(s) occurred during save(): - Field error in object 'com.mydomain.myapp.User' on field 'username': rejected value [facebook_100005487962357]; codes [com.mydomain.myapp.User.username.email.error.com.mydomain.myapp.User.username,com.mydomain.myapp.User.username.email.error.username,com.mydomain.myapp.User.username.email.error.java.lang.String,com.mydomain.myapp.User.username.email.error,user.username.email.error.com.mydomain.myapp.User.username,user.username.email.error.username,user.username.email.error.java.lang.String,user.username.email.error,com.mydomain.myapp.User.username.email.invalid.com.mydomain.myapp.User.username,com.mydomain.myapp.User.username.email.invalid.username,com.mydomain.myapp.User.username.email.invalid.java.lang.String,com.mydomain.myapp.User.username.email.invalid,user.username.email.invalid.com.mydomain.myapp.User.username,user.username.email.invalid.username,user.username.email.invalid.java.lang.String,user.username.email.invalid,email.invalid.com.mydomain.myapp.User.username,email.invalid.username,email.invalid.java.lang.String,email.invalid]; arguments [username,class com.mydomain.myapp.User,facebook_100005487962357]; default message [Property [{0}] of class [{1}] with value [{2}] is not a valid e-mail address]
DefaultFacebookAuthDao.groovy の 149 行目あたり
146: appUser.setProperty(securityConf.userLookup.passwordExpiredPropertyName, false)
147: }
148: AppUserDomainClazz.withTransaction {
149: appUser.save(flush: true, failOnError: true)
150: }
151: }
152: user[appUserConnectionPropertyName] = appUser
DefaultFacebookAuthDao.groovy の 148 行目あたり
145: appUser.setProperty(securityConf.userLookup.accountLockedPropertyName, false)
146: appUser.setProperty(securityConf.userLookup.passwordExpiredPropertyName, false)
147: }
148: AppUserDomainClazz.withTransaction {
149: appUser.save(flush: true, failOnError: true)
150: }
151: }
FacebookAuthProvider.groovy の 67 行目あたり
64: log.error("Can't create user w/o access_token")
65: throw new CredentialsExpiredException("Can't receive access_token from Facebook")
66: }
67: user = facebookAuthDao.create(token)
68: justCreated = true
69: } else {
70: log.error "User $token.uid doesn't exist, and creation of a new user is disabled."
FacebookAuthProvider.groovy の 67 行目あたり
64: log.error("Can't create user w/o access_token")
65: throw new CredentialsExpiredException("Can't receive access_token from Facebook")
66: }
67: user = facebookAuthDao.create(token)
68: justCreated = true69: } else {
70: log.error "User $token.uid doesn't exist, and creation of a new user is disabled."
痕跡
Line | Method
->> 149 | doCall in DefaultFacebookAuthDao.groovy
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 687 | withTransaction in org.grails.datastore.gorm.GormStaticApi
| 148 | create . . . . . . . in DefaultFacebookAuthDao.groovy
| 67 | authenticate in FacebookAuthProvider.groovy
| 40 | attemptAuthentication in FacebookAuthRedirectFilter.groovy
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 724 | run in java.lang.Thread