Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proble with org.grails.plugins:spring-security-facebook:0.17 #97

Open
kikeseiya opened this issue Mar 31, 2017 · 7 comments
Open

Proble with org.grails.plugins:spring-security-facebook:0.17 #97

kikeseiya opened this issue Mar 31, 2017 · 7 comments

Comments

@kikeseiya
Copy link

I have an application with:

  • Grails 2.4.4

  • org.grails.plugins:spring-security-facebook:0.17

  • org.grails.plugins:spring-security-core:2.0.0

The application ran without problems, but these days I get this error:

ERROR facebook.FacebookAuthUtils - No access_token in response:
ERROR facebook.FacebookAuthUtils - No expires in response:
ERROR facebook.FacebookAuthUtils - Can't read data from Facebook
Message: Server returned HTTP response code: 400 for URL: https://graph.facebook.com/me?access_token=null

Any ideas please....

thank you

Enrique

@martinduris
Copy link
Contributor

confirm - same problem

@kikeseiya
Copy link
Author

Yes, it is same problem...

@martinduris
Copy link
Contributor

Hi, please upgrade to version 0.19 - author of this plugin already fix it there :-)

@kikeseiya
Copy link
Author

Hi, doesn't work because facebook 0.19 only works with Grails 3.x and Spring-Security-Core plugin 3.x.

Mi application work with Grails 2.4.4 and Spring Security Source 2.0 :(

@martinduris
Copy link
Contributor

@kikeseiya hmm, maybe there is need to create fork ?

@kikeseiya
Copy link
Author

I modified the code with the new facebook format and it works.

@kikeseiya
Copy link
Author

`FacebookAccessToken requestAccessToken(String authUrl) {
try {
URL url = new URL(authUrl)
String response = url.readLines().first()
println "AccessToken response: $response"
println response.split(',')
Map data = [:]
int i = 0
response.split(',').each { String part ->
part = part.replace(""", "")
if (i == 0) {
part = part.substring(1)
}

			if (i == 2) {
				part = part.substring(0, part.length() - 1)
			}
			
			i++
			println part
            String[] kv = part.split(':')
            if (kv.length != 2) {
                log.warn("Invalid response part: $part")
            } else {
				println kv[0] + " " + kv[1]
                data[kv[0]] = kv[1]
            }
        }
        FacebookAccessToken token = new FacebookAccessToken()
        if (data.access_token) {
            token.accessToken = data.access_token
        } else {
            log.error("No access_token in response: $response")
        }
        if (data.expires_in) {
            if (data.expires_in =~ /^\d+$/) {
                token.expireAt = new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(data.expires_in as Long))
            } else {
                log.warn("Invalid 'expires' value: $data.expires")
            }
        } else {
          log.error("No expires in response: $response")
        }
        //log.debug("Got AccessToken: $token")
        return token
    } catch (IOException e) {
        //TODO process error response
        log.warn("Can't read data from Facebook", e)
        return null
    }
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants