REST API to get currently logged in user's username confluence server - confluence

I am using confluence server 7.13.7. I want a REST API to get the currently logged-in user's username so I can use it in other API calls to fetch more details about the user further.
I know of a way by using the snippet:
var userFullname = $("#user-menu-link").attr("title");
to get the current user's username. But, in my use case; I am in need of a REST API.

example: (GET)
/rest/api/user/current
from official documentation:
https://docs.atlassian.com/ConfluenceServer/rest/7.13.0/#api/user-getCurrent

Related

Linkedin REST API retrieve status updates of a user

I'm trying to retrieve the status updates of the authenticated user with the REST API. Is there a way to do that? I only can find a way to retrieve the status updates of the companies the user has admin rights of.
It is no longer possible with the standard LinkedIn API (If you look at their REST console, you can see all the public methods: https://apigee.com/console/linkedin?apig_cc=1).
You now need to join their partner program in order to access additional API methods now: https://developer.linkedin.com/partner-programs

Get authenticated user information in Azure Api App

Context
I have a Azure Api App set as "Public (authenticated)" and have enabled Facebook identity. My Api App is protected and I am able authenticated with FB. In the Api App, I want to get the authenticated user information such as login provider, token and email to save in a database.
Problem
I can't find any documentation on how to obtain this info. I followed this article and tried
var runtime = Runtime.FromAppSettings(Request);
var user = runtime.CurrentUser;
TokenResult token = user.GetRawTokenAsync("facebook").Result;
var name = (string)token.Claims["name"];
var email = (string)token.Claims["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"];
I've made the changes to the apiapp.json file to allow facebook authentication "authentication": [{"type": "facebook"}] but it times out at GetRawTokenAsync when remote debugging the Api App.
Looking at other blogs/articles/posts, following is another way by referencing additional assemblies "Microsoft.WindowsAzure.Mobile"
var user = (MobileAppUser)this.User;
var facebookCredentials = user.GetIdentityAsync<FacebookCredentials>().Result;
But this also doesn't work as this.user is of type WindowsPrincipal user when remote debugging my Api App. And apparently "Microsoft.Azure.AppService.ApiApps.Service" is the only reference an Azure Api App needs.
Am I missing something? Seems like a basic scenario to get the authenticated user in a Api App web service.
Finally got it to work. When calling GetRawTokenAsync method we must await. Using Result or Wait from the Task object doesn’t work and times out. This is still unclear to me why, perhaps a framework bug?

Is there Box rest api to fetch folders connected to a user?

Below rest api provides the membership details of a box user:
https://api.box.com/2.0/users/335014321/memberships
Is there a similar api that will fetch folders connected to box user?
I have tried below rest endpoint but gave response status:
405,"code":"method_not_allowed".
https://api.box.com/2.0/users/335014321/folders
You would probably not be able to get the folders connected to a box user without the oauth token from that user.
If you are an admin of a box enterprise account. You can use the As-User header. You can take a look at this
https://box-content.readme.io/reference#as-user-1
You would have to get an access token as an admin to be able to use the As-User call as well as sending a Support Ticket to Box Support to ask them to activate your application to allow the usage of As-User.

REST related query- for use in Java web app

I am trying to create a REST API using Java.
Now, for the front end, I am using socialauth, so that facebook/twitter/yahoo/hotmail/gmail users can sign in to the application.
After a user is signed in, he should be able to access the data for his account- I want to create a REST API that enables each user to access his data. I have understood the basics of creating a REST API using Jersey framework, however how do I ensure that only a user who is correctly logged in to the application, can access data via the REST API?
What I thought of is, I will store the user's email ID in session, when he logs in. And whenever he makes a request to the API, the email ID in session is passed as a input parameter to the REST API, and the REST API checks that data is asked for same email ID, as the email ID parameter.
Is the above way of thinking correct? What is the recommended/best way to implement REST API in the scenario as given above?

How can I fetch data from facebook using a query string in salesforce?

How can I fetch data from facebook using a query string in salesforce?
This is what I have:
I am not fetching data so what can I do?
Have you called Http's send method after this?. I guess you have but are not getting any response back?
Any external site you call from Apex must be registered in the Remote Site Settings. Make sure to add Facebook's URL under Admin Setup > Security Controls > Remote Site Settings