facebook,grails,spring-security,spring-social , Why does the Spring Social plugin occasionally return an empty email on the User class?


Why does the Spring Social plugin occasionally return an empty email on the User class?

Question:

Tag: facebook,grails,spring-security,spring-social

I have a Grails project (v2.4.2) that is making use of the spring-security-facebook:0.17 plugin to authenticate via Spring Security. At first sight, all seems well. However, there is a large set of users that for some unknown reason I cannot access their email address. I am using spring social to grab the email. I have permission and it is set in the scope. Here is a code snippet where I authenticate a new user:

log.info("Create domain for facebook user $token.uid")

//Use Spring Social Facebook to load details for current user from Facebook API
log.info("create: FacebookAuthToken: $token")
log.info("created FacebookAuthToken.FacebookAccessToken = ${token.accessToken}")

Facebook facebook = new FacebookTemplate(token.accessToken.accessToken)

org.springframework.social.facebook.api.User fbProfile = facebook.userOperations().getUserProfile()

// Check if email is actual granted because in production some are coming back null
boolean isEmailGranted=false
List<Permission> permissions = facebook?.userOperations()?.getUserPermissions()
String permissionString = "["
for (int i=0;i<permissions.size();i++) {
    permissionString += "["+ permissions[i].getName() + ":" + permissions[i].getStatus()+"]"
    if (permissions[i].getName()=="email" && permissions[i].isGranted())
        isEmailGranted=true
}
permissionString += "]"
log.info("create: Facebook Permissions = " + permissionString)

def grailsWebRequest = WebUtils.retrieveGrailsWebRequest()
def flash = grailsWebRequest.flashScope

if (!isEmailGranted) {
    log.warn("create: Unable to subscribe facebook user because email priviledge was not granted.")
    flash.message = 'Login to Facebook failed. We must have access to your email address in order to proceed with login.'
    throw new InsufficientAuthenticationException("Facebook email not accessible")
}

log.info("created: ")

String email = fbProfile.getEmail()
String firstName = fbProfile.getFirstName()
String lastName = fbProfile.getLastName()
String fullName = fbProfile.getName()
String username = firstName
String password = token.accessToken.accessToken

if (!email) {
    log.error("create: Permission was granted to use facebook email but the value is null.")
    flash.message = 'Login to Facebook failed. We are temporarily unable to access your email although permission has been granted'
    throw new InsufficientAuthenticationException("Facebook email not accessible for unknown reason")
}

Why would I receive an empty email when permission has been granted? Is there a preferred method for handling this behavior (other than failing the authentication and making up a fake email address). Many thanks!


Answer:

The documentation for the 'email' field of the 'user' object ( https://developers.facebook.com/docs/reference/api/user/ ) clarifies the expected behaviour here, which is: "this field will not be returned if no valid email address is available"

There is a detailed explanation about different situations where an email won't be sent. Please check it out: https://developers.facebook.com/bugs/298946933534016/

I hope it helps.


Related:


Agree to my privacy policy when sign up to my site via facebook


facebook,privacy,policy
My site has privacy policy and terms of service, when user registered required to agree to both of them. But also I have option of sign up with facebook. Do user required to agree to my privacy policy and terms of service when signing up to my site with facebook?...

Using Graph API Explorer gets friends list but my own app doesn't . (Graph API Explorer token v.s App Token)


facebook,api,facebook-graph-api
I am trying to get my friends list in my app. If I use the access token in my Graph API Explorer console and hit the url. https://graph.facebook.com/v2.3/me?access_token='GraphAPIToken'. I am able to get the complete friends list. If I try using the SDK or any library like fbgraph for nodejs...

Grails: Do addTo* and removeFrom* require a call to save?


grails,gorm,grails-2.0,grails-domain-class
In the docs some examples have a call to save whereas some others do not. I'm assuming that addTo* needs the call to save whereas removeFrom* doesn't. Am I mistaken?

Facebook Debugger Returning “Document returned no data”


facebook,facebook-graph-api
Recently I noticed that Facebook's Object Debugger was unable to scrape any pages of my website. After troubleshooting and scouring the internet, I'm at a loss for what might be causing this bug. Whenever I attempt to fetch a new scrape of my website, the following error is returned: Error...

Facebook Android API asks for additional permission


android,facebook,facebook-graph-api
I am using v2.3 api here I can login with Facebook login button. Now how can I call additional permission on click? I have looked through answers for this question, but all of them look to be back-dated. Can someone show me the right way of asking for addition permission...

Grails JAX-RS Calling a class in src/groovy giving error - Message: No signature of method: is applicable for argument types


grails,groovy,jax-rs
While developing the rest api using jaxrs plugin I need to create some common class which I have created in "src/groovy". Below is the class class ValidateToken { String validate(String token){ println(token) return "test" } //... In resource file(jaxrs) this is what I am doing def instance=ValidateToken.validate("test") This throws error...

Creating a website for a restaurant with facebook api [closed]


php,facebook,facebook-graph-api
I've my own webdevelopment company and I have a new customer this week who wants to have a facebook API on his site. I've worked with the API before for my personal website but never with a customer. And my question was what is the best way to get a...

Facebook LogIn and Parse


android,facebook,parse.com,facebook-javascript-sdk
I've just added Facebook login to my app, I can retrieve the data I need. But I'm not completely sure what to do with it. My app already works with normal users to Parse.com (which I registered on a register screen that I have created in my app). But what...

how to share screenshot to Facebook


objective-c,facebook,facebook-sdk-4.0,social-media
I've already done that screenshot part, but still haven't found any solution to share the screenshot image to Facebook by using FBSDKSharePhoto. Facebook doesn't provide enough references for it. Can anyone please guide me here? Here is my screenshot code just in case: CGRect screenRect = [[UIScreen mainScreen] bounds]; UIGraphicsBeginImageContextWithOptions(screenRect.size,...

Facbook Friends Likes count for a page in html


html,angularjs,facebook,social-likes
I want To Display count that number of friends liked a page in html anyone please tell me and i know by using simple url we can get the page likes but i want know how to get the count of friends who liked a page and that too i...

I need to retrieve facebook user language with php


facebook
I'm building a very simple facebook app in which i would like to retrieve the facebook user language. Since now, i retrieve the browser language to give the right language for the user but I think that retrieving the facebook user language is better and more precise. Is there someone...

Error when using angular with Grails


angularjs,grails
Here is my index.gsp <!DOCTYPE html> <html ng-app="myApp"> <head> <title>my app</title> </head> <body> <input type="text" data-ng-model="test"/> {{test}} </body> <script src="/js/angular.min.js"></script> </html> When I build an app, There is an error like this, Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=myApp&p1=Error%3A%…20at%20d%20(http%3A%2F%2Flocalhost%3A8000%2Fjs%2Fangular.min.js%3A17%3A381)...

Facebook user to Parse.com


android,facebook,parse.com,facebook-login
How do I get the data from The Facebook user to Parse.com? The code that I will provide below makes a user but it doesn't update it with data when I login, why is it not working? public class LoginActivity extends Activity { private EditText usernameView; private EditText passwordView; @Override...

Grails: Carry forward params on g:actionSubmit is clicked


grails,gsp
How to carry forward the parameters when g:actionSubmit button is clicked? Here is my gsp code: <g:checkBox name="msgCheck" checked="" value="${userInstance.emailId}"></g:checkBox> ... <g:actionSubmit class="update" action="delete" value="Delete" params="${params}"></g:actionSubmit> Here is my controller code: def delete() { try { def user_list = params.msgCheck //deleting the user //successful. redirect(action: "list", params: params) } catch...

Grails logging auto inject


grails,logback
I use grails 3.0.2 and logback. How can I use this logger in my code, can I somehow autoinject it, like log.debug() in grails 2.x which was using org.apache.commons.logging.Log?

need a neat way to create a dynamic facebook sharing technique with custom parameters


jquery,facebook
Since Sharer's ability to accept custom parameters is dead which was the easiest way for a noob like me, I am a bit puzzled with all the FB.ui n OGP talk everywhere. I am not sharing via any app. So do not suggest a method that needs any app_id. I...

Graph API get user id facebook


facebook,facebook-graph-api
How can I do this? Im using Graph API v2.3 I am able to get the access token, but I don't know how to get the user's ID....

django get the social token form allauth


python,django,facebook
Hello i tried to get the social token from the DB but i get this error. I can't find any answer to this and tried everything i can think of. Please if anyone knows how to fix this. NameError at / name 'user' is not defined Request Method: GET Request...

login with facebook and capture photo via Camera and share on own wall


java,android,facebook,camera
I searched many sites, but I still can't solve this issue, the problem is that I can't seem to be able to post the data. My code: public class MainActivity extends Activity { // Your Facebook APP ID private static String APP_ID = "397909153726269"; // Replace with your App ID...

Facebook API profile picture


javascript,html,css,facebook,facebook-graph-api
I created a website for my Students Organization. On that website there is a page where I list all the people who helped organize our Activities. Theres a picture of every member there. To get the images, I used their facebook profile pictures. I used http://graph.facebook.com/USERNAME/picture?height=250&width=250 This code did work...

passing backbone collection to view


grails,backbone.js,handlebars
I'm just starting out with backbone / grails and i've been struggling to figure out how to get everything to work. I'm building a pricing configurator where a user selects a product type from radio group A and radio group B containing the quantity / pricing / discount data will...

Facebook - “Cannot query users by their username” solution


android,facebook,facebook-graph-api,facebook-graph-api-v2.2
I am developing an android app. I was using a HttpURLConnection to get profile pictures of facebook users. The URL looks like this: http://graph.facebook.com/?ids=username1,username2,username3&fields=picture&type=square But now, since v2.2 doesn't let me to get profile pictures of users who are not using my facebook app, it throws an error: { "error":...

Facebook Marketing API some field are not shown


facebook,facebook-opengraph,facebook-ads-api
I have a development level access to Marketing API and it looks like I cannot read some fields of specific objects. For example I try the following call: You can see that promoted_object, link_url and object_url are not displayed in the result. And I should have one of those three...

Unable to share message in Facebook API 4.0, with error : Error publishing message


android,facebook
Currently using Facebook 4.0 API, I try to publish message, but I receive the error as following: Error: Error publishing message Looking for help on this issue. private CallbackManager callbackManager; private ShareDialog shareDialog; private FacebookCallback<Sharer.Result> shareCallback = new FacebookCallback<Sharer.Result>() { @Override public void onCancel() { Log.d("HelloFacebook", "Canceled"); } @Override public...

Opening facebook in a panel of winforms


c#,multithreading,facebook,panel,process.start
I am in need to open facebook(whatsapp,skype etc) with in a panel. please suggest something to achieve the same. I working on windows 7. If facebook is not possible then please suggest with whatever the task is possible whether with facebook messenger,whatsapp (site or app),skype or any other social networking...

Login with Facebook option trigger suggest to download an app


android,ios,facebook,osx,login
Yesterday I logged in to Airbnb with my Facebook account on my OSX. Shortly later I got a notification both on my iPhone and computer saying "Airbnb is available to install on your iPhone" My question is, does anyone here know how this was done? Is this a feature available...

Does Facebook allow preloading a specific message from a user to a page?


facebook,webintents
I know that Facebook allows web intents of sharing URLs, along with the ability to select whether it goes into a message, or to your wall, but I was wondering if there is an ability to do something where a user can click a link/button, and it opens up a...

angularjs ngfacebook batch request


angularjs,facebook,facebook-graph-api
Can anyone who knows how to use the angularjs ngFacebook module help me to perform a facebook batch request? Is it possible to do it with this module? What I need exactly is to get the user events from facebook, for that I have to do 4 different request: $facebook.api('/me/events/attending').then(function(response)...

Facebook Permission Graph API


php,facebook
try { $response = (new FacebookRequest($session, 'GET', '/me/permissions'))->execute(); $object = $response->getGraphObject() -> asArray(); echo '<pre>'; print_r($object); echo '</pre>'; //problem lies over here for($i = 0 ; $i <count($object['data']); $i++){ echo "<br>" . $object['data'][$i] -> permission; } } catch (FacebookRequestException $ex) { echo $ex->getMessage(); } catch (\Exception $ex) { echo $ex->getMessage();...

grails DataSource.groovy refer bean for decoding password


grails
Referring https://jira.grails.org/browse/GRAILS-3620, we need to specify a class with static methods to decode the encrypted password in DataSource config. For passwordEncryptionCodec property, is it possible to refer to a bean defined in resources.xml or any other grails bean definition files? For ex: having a decrypted Properties bean in resoures.xml or...

Access Token of Facebook changed by user, How to get call back for Access Token?


android,facebook,facebook-access-token,android-facebook
I am using Facebook SDK 4.2. I have implemented AccessTokenTracker interface, which is working if token is changed. My question is : If user got publish_permission for post something from Android app. Then I remove that permission from my Facebook account. Now in app, the token return from AccessToken accessToken...

[B cannot be cast to java.sql.Blob


grails,gorm
This is my domain class class TimesheetSubmission { Date submissionDate=new Date() String foreman String shift String jobId Date date byte[] xmlSubmission String xmlResponse static constraints = { submissionDate nullable: false foreman nullable: false shift nullable: false jobId nullable: false date nullable: false xmlSubmission nullable: true xmlResponse nullable: false } static...

Log Grails Pre 3.0 startup time


grails
In Grails 2.x.x is it somehow possible to log the startup time? We are currently trying to optimize the application startup and having the startup time logged would help tremendously.

Grails 3.0 Searchable plugin


maven,grails
I've tried to use the searchable plugin in grails 3.0, but I am not sure wheather it is compatible or not. I've added compile "org.grails.plugins:searchable" to the dependencies. The build completes but yields a NotSearializableException: > Configuring > 1/1 projects > Resolving dependencies ':agent' > Resolving dependencies ': BUILD SUCCESSFUL...

Render a controller into a String


grails,grails-2.0
I can render a template or a view into a String, but how can I render a controller into a String ? I would like to perform this kind of operation: def myAction = { ... def html = renderToString(controller: 'myController', action: 'myAction', params: [what:'ever']) render modify(html) ... } ...

Facebook SDK 4.2 FBGraphUser protocol update


ios,facebook,facebook-graph-api
I am working on an Xcode project that has Facebook SDK 3.1.4. I am currently updating the SDK to 4.2. I was just wondering if someone can help me with the update related to FBGraphUser protocol and how I can update that for Facebook SDK 4.2. I have looked around...

Fetching Data From Multiple Facebook API's then Adding Together


javascript,jquery,facebook
JQuery Snippet // THE FOUR URL'S TO ADD THE TOTAL SHARES var Gal_All = "Link One"; var Gal_S_1 = "Link Two"; var Gal_S_2 = "Link Three"; var Gal_S_3 = "Link Four"; $.ajax({ type: 'GET', url: 'https://graph.facebook.com/' + Gal_All, success: function(data) { showCount(data); } }); var fbshares; var fbcomments; function showCount(responseText)...

unable to resolve class org.apache.commons.net.ftp in grails


grails,apache-commons
I am developing a module in which some file need to be uploaded on a ftp server for that I have added the "commons-net-3.3.jar" in my grails app & while using it import org.apache.commons.net.ftp.FTP import org.apache.commons.net.ftp.FTPClient import org.apache.commons.net.ftp.FTPClientConfig import org.apache.commons.net.ftp.FTPFile import org.apache.commons.net.ftp.FTPReply It is throwing the error unable to resolve...

alert grails pagination current offset value


grails,pagination
I am using Grails 2.4.2. I have a list which is using pagination. When I mouse hover a number or next page icon it shows current offset number as tool tip. Can I alert this offset number or get my list's current page offset number?

Bluemix authentication ios8 with google and facebook


facebook,authentication,ios8,bluemix,google-authentication
I am trying to implement two types of authentication from an iOS8 device in the bluemix platform. I succeeded in adding one type of authentication: google. I am using a ADVANCED MOBILE ACCESS module, and I am at the User Authentication part. It looks from a dashboard like I can...

Facebook logout iOS SDK


ios,objective-c,iphone,facebook
In the latest SDK of Facebook for iOS 8, the login button itself changes to logout once the user logs in successfully. I have a separate logout button in my applications. When the user is successfully logged in using my own server credentials, google+ or facebook, the app takes the...

facebook post on page wall - PHP SDK


php,facebook,facebook-graph-api,facebook-php-sdk
I'm trying to create a script that post on a facebook page (as an administrator) a status. This is the script i'm using: try { $access_token = (new FacebookRequest( $session, 'GET', '/' . $pageID, array( 'fields' => 'access_token' ) )) ->execute()->getGraphObject()->asArray(); $access_token = $access_token['access_token']; $page_post = (new FacebookRequest( $session, 'POST',...

Groovy - timestamp from minutes


oracle,grails,groovy,timestamp
I have an array or times/values coming back to be in an array like: [0, 60] Which are times in minutes, 0 = 12:00 a.m, 60 = 1:00 a.m. I am wanting to store these in an oracle database as timestamps. How do I convert minutes into timestamps in groovy?...

File upload with grails and jquery


jquery,grails
I have a form with multiple inputs plus a doc or pdf file upload. //Multiple input fields are here then upload -> <div class="controls"> <div class="fileupload ${ person?.attachment ? 'fileupload-exists' : 'fileupload-new' }" id="attachment" data-provides="fileupload" data-name="attachment"> <span class="btn btn-file"> <span class="fileupload-new">Add</span> <span class="fileupload-exists">Change</span> <input type="file" /> </span> <span class="fileupload-preview"></span>...

grails 3.0.1 scaffolded view does not show domain relationship


grails,scaffolding
I am following the example in the book "Grails a Quick-Start Guide" using Grails 3.0.1 with following domains package com.tekdays class TekEvent { static constraints = { name() city() description maxSize:5000 organizer() venue() startDate() endDate() } String city String name TekUser organizer String venue Date startDate Date endDate String description...

Intercepting login calls with Spring-Security-Rest plugin in Grails


rest,grails,spring-security
I am using the spring security rest plugin for Grails to provide a login mechanism for an AngularJS app. Login works fine, but I can't figure out how to intercept login calls, in order to store additional statistics on (invalid/valid) login attempts. As I am quite new to Spring Security...

difference between componentDidMount and getInitialState in Reactjs


facebook,reactjs,flux
I understand that getInitialState is called once in the component's lifecycle and componentDidMount is called when the component is rendered. So does that mean both will get called just once in the component's lifecycle? What's the difference?...

In Facebook marketing API, where to set target URL of an Ad Campaign


facebook,facebook-graph-api,facebook-ads-api
I would like to create an Ad Campaign with the Marketing API but I don't know where I can set the target URL of this campaign. I can set the objective of the campaign to WEBSITE_CLICKS but where to set the URL it will goes to? If I use the...

How to declare javascript asset in the view to be rendered within the footer using Grails Asset Pipeline


grails,grails-plugin
Since there is no deferred option for: <asset:javascript src="custom_view_script.js"/> What else can be used, outside of resource plugin, to place view specific script right before the closing body tag and without declaring it globally in layout? I do know about: <asset:deferredScripts/> but that only handles on page script and not...

Decode base64 image in Grails [duplicate]


grails,groovy
This question already has an answer here: Convert base64 string to image 3 answers I have a post api where I am sending a json string which contain the base64 encoded image.Below is the json string { "imageData":"base64encoded string", "status":"1" } where base64encode string is iVBORw0KGgoAAAANSUhEUgAAAHgAAACgCAIAAABIaz/HAAAAAXNSR0IArs4c6QAA\r\nABxpRE9UAAAAAgAAAAAAAABQAAAAKAAAAFAAAABQAABWL3xrAqoAAEAASURBVHgB\r\nlL2Fe1t7mueZme6uewNGMUu2LNkyySSjDJKZmZkSO8zM7CTmmJnZYbxUVbdgsKp7\r\nqqdrdp I cant post...