How can I get twitter email Id on my web site.
I am using twitter4j api.
But while getting email it shows
Email: Twitter does not provide this!
In twitter4j api no method available to get email
user = twitter.showUser(twitter.getId());
twitterUser = new TwitterUser(user.getId(),user.getName(),user.getScreenName(),user.getLocation(),
user.getDescription(),user.getProfileImageURL().toString(),
user.getFollowersCount(),user.getFriendsCount(),user.getFavouritesCount(),user.getStatusesCount(),
user.getListedCount(),user.getCreatedAt().toString(),user.getTimeZone(),user.getUtcOffset(),
user.getLang(),user.getURL()!=null?user.getURL().toString():null);
Is there any way to get this.
Is there any othe api to get email and /FirstName/LastName .
Please suggest any solution for this.
Twitter does not provide an API for email retrieval. From their FAQ:
How do I obtain a user's email address?
If you'd like a user's email address, you'll need to ask a user for it within the confines of your own application and service. The Twitter API does not provide the user's email address as part of the OAuth token negotiation process nor does it offer other means to obtain it.
If you have a user's ID or screen name, you can get any additional information from the Twitter4J User interface.
Related
I've recently faced a problem.
My frontend use Oauth2 to authenticate my user on Azure (Organization). This giives me multiple information containing idToken and accessToken.
My Backend uses AADResourceServerWebSecurityConfigurerAdapter to authenticate the user thanks to the idToken put in the Authorization Bearer header from the frontend.
Unitil here everything works well. I can get the connected user with this:
public static String getConnectedUserEmail() {
return (String) ((AADOAuth2AuthenticatedPrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getAttributes().get("preferred_username");
}
I use my backend app credentials to contact the graph api on behalf of the API itself.
Though, following Azure Ad documentation, I cannot query group/calendar on behalf of the API, I have to do it on behalf of the user.
To respect SOLID principles, I want to make the request from the backend, but on behalf of the user.
I cannot find any information about that.
So here is my final question: How can I make a graph API request in my backend on the behalf of the user?
Knowing that trying to use the tokenValue (idToken) of the user or the accessToken value returns invalid credentials from Microsoft.
You requested GET /groups/{id}/calendar to get group calendar as you said.
You can call Graph API with the access token using on-behalf-of flow, see here.
There is a sample using the On-Behalf-Of flow: https://github.com/Azure-Samples/ms-identity-java-webapi
Note: Make sure the following delegated permission is added.
Im creating an application to login in Google+ and get friends emails.
Im authenticating succesfully and get token back , but when i fetch friends list , the user class of any single friends has emails=null...
here is the code (After already signed in and get authenticator class):
// Generated libraries for Google APIs
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Services;
using Google.Apis.Util;
using Google.Apis.Plus.v1;
using Google.Apis.Plus.v1.Data;
// For OAuth2
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth2;
//....code for authentication skipped ....
//...callback from json (authentication success)
PlusService ps = new PlusService(new BaseClientService.Initializer()
{
Authenticator = authenticator
});
PeopleFeed peopleFeed = ps.People.List("me", PeopleResource.CollectionEnum.Visible).Fetch();
//After that when i inspect peopleFeed[0].Emails <--- this is null..
any help?
The Google+ API only returns public information. So even if you are permitted to see a person's email address, it does not necessarily mean that the information is public and that it will be returned.
Furthermore, the documentation at https://developers.google.com/+/api/latest/people/list only guarantees that the list of people returned will contain the person's
id
displayName
image
url
and that to get other information about the person, you will need to do a people.get against that ID. But, again, note that you may still not get their email if that information isn't public.
You could also use the Contacts v3 API to get friend's email addresses. You can cross map this to Google+ contacts by looking at the gContact:website element for the contact that comes back in the XML response:
<gContact:website href='http://www.google.com/profiles/1234567890' rel='profile'/>
In that element's href attribute, 1234567890 is the person identifier that would match the id field of the relevant person resource from people.list of the Google+ API.
Note that the profile link is not guaranteed to come back for a contact entry. This occurs when the contact has not been linked to a Google+ profile.
My first guess would be that it's a rights management issue. I remember when I asked for my Google API key, I had to mention what information I want to get.
Could you check your API key settings in the Google Developer network and see if you need to enable it there?
I'm using RestFB facebook API in JAVA.
What i need to do is to get: users likes,users friends list, users friends likes.
what is the right flow to do it?
Do i need to build an application on facebook that the users will approve and then connect to this application?
I'm very confused with the correct way to implement it :|
thanks!
There's a step by step guide on facebook developers website.
You have to work with an access token that will allow you to use a user's facebook account. Once you've the access, call the appropriate api with user permission to fetch information like basic profile info, friends list, photo, etc.
The RestFB api is open source and is quite good, I haven't had the chance to work with it yet but before using it create a Facebook application and request an OAuth access token. And then proceed as illustrated on the RestFB page.
Something like this:
FacebookClient facebookClient = new DefaultFacebookClient(YOUR_ACCESS_TOKEN);
User user = facebookClient.fetchObject("me", User.class);
Page page = facebookClient.fetchObject("cocacola", Page.class);
out.println("User name: " + user.getName());
out.println("Page likes: " + page.getLikes());
Can twitter4j get the email of twitter users authorizing an application/web site.
I was able to get the screen name as below:
User user = twitter.showUser(id);
String screenName = user.getScreenName();
How about the email? Is it possible?
Thanks.
You can get the user details using the below API: http://api.twitter.com/1/users/lookup.xml?user_id=YOUR_USER_ID
Twitter says it doesn't provide any API for email retrieval. https://dev.twitter.com/docs/faq#6718
My application uses 3-legged authentication (OAuth).
I have the token (user was redirected to google login page to log in)
How can I get the e-mail address he used to authenticate?
you should look up user data using the access token. in facebook, the access token starts with user serial, so you can identify user from token directly. (ex. 123456-someStrangeStringBlahBlah...)
so if exposure of user serial is not problem, make token like facebook.
I think you want to use OpenID attribute exchange. (not OAuth, but Google has a bridge between the two).
See Google's page on their federated login API.
If you are using OAuth1.0 you can extract user email from the contactService by making a request to get for example contact group id. The returned response contains the user email encoded:
"http://www.google.com/m8/feeds/groups/user_email_here%40gmail.com/base/5f062e1e08cb3123"