I have existing code that uses a constant value for clientID to fetch a FacebookPage access token. That static value comes from when I deploy to GAE. But since I have many appIDs, I would like this to be dynamic instead. This is the line that completes the authorization and spits out a code:
String url = "https://www.facebook.com/dialog/oauth" + "?client_id=" +
FacebookHelper.app().getAppId() + "&redirect_uri="
+getCallbackUrlForPageManager(stationId) + "&scope=" + permissions;
So instead of FacebookHelper.app().getAppId() (the constant value), I fetch a station object from stationID, and then fetch its String AppID.
I have absolutely, 100%, confirmed that the request and callback URLs match:
I've tested with an without a forward slash (/) at the end of my redirectURI at the suggestion of other resolved questions. With the static clientID all completes just fine without the slash at all.
When I use the dynamic app ID (and both URLs still match exactly), I get this error without a slash:
Uncaught exception from servlet
dwinq.common.social.FacebookAuthorizationCodeUsedException: Internal Facebook Exception: 100 message: 'Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request
at dwinq.spoke.servlet.FacebookOAuth.callOAuth(FacebookOAuth.java:280)
at dwinq.spoke.servlet.FacebookOAuth.fetchTokenFromCallback(FacebookOAuth.java:850)
at dwinq.hub.servlet.FacebookPageOAuth.fetchTokenfromCallbackForPageManager(FacebookPageOAuth.java:98)
at dwinq.hub.servlet.FacebookPageOAuth.acceptedPageManagerPermissions(FacebookPageOAuth.java:73)
at dwinq.hub.servlet.FacebookPageOAuth.handle(FacebookPageOAuth.java:30)
at dwinq.common.servlet.AbstractServlet.doGet(AbstractServlet.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
....
And when I do use a slash, this error:
Uncaught exception from servlet
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:450)
at java.lang.Long.<init>(Long.java:690)
at dwinq.hub.servlet.FacebookPageOAuth.acceptedPageManagerPermissions(FacebookPageOAuth.java:41)
at dwinq.hub.servlet.FacebookPageOAuth.handle(FacebookPageOAuth.java:30)
at dwinq.common.servlet.AbstractServlet.doGet(AbstractServlet.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
....
Any thoughts? If more info is needed I can provide specific info.