SpringCloud, How to get data from another micro-service - microservices

Now I has 2 micro-service in my project
User-service : for user login
Article-service : ( user can publish and browse the article )
When the user publish an article, Article-service will save the
(userId, articleContent) to the db
When the user query the article list, I want to return the article list and user info(like nickname, avatar)
So in the Article-service, how can I get every user's info from the User-service

Related

Set User as the owner of an item they created on Strapi v4. Relationships

I am creating a website which allows users to create an ad before they are registered.
I have the default User collection type and also created an Ads collection type. Ads have a relation to User as the creator of the ad. Note that when the Ad is created the user is not logged in.
Users visit the site and they start creating the ad by filling up a form with:
Title
Product Description
Then when they are done filling the ad info they are asked to register.
When they click to register, the frontend calls Strapi and creates the user.
Then it gets the user id and creates the ad with the user id as the 'creator'.
The problem is Strapi is not creating the relation unless I set my User 'find/findOne' function to public.
Is it possible to create the relation without making it so that people can find users through the api?

URL block based on entity variables

I am working on a Spring Boot & Spring Security project where a user can add flights to his trip if the trip has been approved (user entity contains a status variable that can be changed by the admin to approved or denied for the trip) by an admin.
As long as the trip has pending/denied status the user should not be able to access the flights url. How can I achieve this blocking functionality based on that user variable?
Trips url: http://localhost:4040/user/{userId}/trip
Flights url for a specific trip: http://localhost:4040/user/{userId}/trips/{tripId}/flights

Microservices - Should you separate user accounts from profile information?

For example:
Accounts Microservice - Handles authentication and stores email, password.
Profile Microservice - Fetched when displaying identity information name, age, gender, address, etc.
Or is this overkill and just a single Users Microservice would suffice?

Getting user gender via spring social for facebook

We have developed an app that let user login with facebook. The app has been granted all required permissions to retrieve name, email, gender and age range etc. But our app developer stored only id,name and email while user login. Now we need to retrieve gender and age range of all those users who have logged in the app.
Is there a way to rerun user query to retrieve those data? I am looking to develop an program using Spring-social and RestFB but it needs user login action to retrieve required data which is problem in our case since we cannot recreate login action again.
As long as the user granted public_profile permission to your app, and you have their app-scoped user id, you can make the API call using your app access token.
And if you are looking to request this data for a lot of users, then you should optimize your requests in the following ways:
request the fields you need only: /user-id?fields=id,gender
request data for multiple users in one go: /?ids=user-id-1,user-id-2,user-id-3&fields=fields=id,gender – https://developers.facebook.com/docs/graph-api/using-graph-api/v2.5#multirequests
perhaps even use Batch Requests if necessary, https://developers.facebook.com/docs/graph-api/making-multiple-requests/

Spring Social Facebook: how to get post's owner which is liked by authenticated user

I have developed a Spring application which uses Spring Social Facebook, in order to get users activities in social network.
I need to know how i can get post's owner which is liked by authenticated user, and which permission is required to perform this operation.
For sake of clarity: User A (authenticated) likes a post belonging to user B. How i can get user B?
Any ideas?
Here you have url from facbook api explorator
me/posts?fields=from,message,picture,icon
This rest execution should return all posts - posted by current user and other users which was liked by him/her. Know you have to write it in Java, below code fetches data from the specified connection.
facebook.fetchConnections(null, "music", Page.class,
new PagingParameters(25, 0, null, null).toMap(), "from,message,picture,icon")
You can also try (but this I haven't tested)
facebook.fetchConnections(null, "posts", Post.class)

Resources