MobileServiceClient LoginAsync returns wrong userId - authentication

I am using the MobileServiceClient.LoginAsync function to login with a Microsoft- and Facebook account in my Xamarin.Forms app. I came across an issue where the loginAsync returns the wrong userId the second time I login:
Lets say my facebook userId is: facebook:11111 and my Microsoft userId is: microsoft:22222. If I login with facebook first, the correct userId is returned. If I login with Microsoft after that, the following userId is returned: microsoft:11111 (instead of microsoft:22222). The same happens when I first login with the Microsoft account, the second time I log in with facebook, the facebook userId is facebook:22222 instead of facebook:11111. I use the following code to login:
var client = new MobileServiceClient(applicationUrl, applicationKey);
client.LoginAsync(provider);
I have also tried to logout first before logging in but has no effect. Am I missing something or is this a bug in the MobileServiceClient?

Apparently this is a known server bug in Mobile Services with a .NET backend: more info

Related

POST login data which has Identity server assigning random ID - Not able to test API using postman

Steps
Using Chrome Postman url - www.test.com/identity/custom/login (sorry cannot give actual URL as it is against company policy)
Note :- Identity server generates the above id every time when user clicks on login
Now when I use Chrome Postman and Post taking id from log in URL to test POST API I get 200 ok, but I am not logged in.)
Any pointer guys on how to handle ID generated by Identity server (.net frame work)
I need to get this working in order to perform load test and Login is important before I am attaching screen shot of my Postman screen
You do not go directly to the login view. You use the /authorize endpoint to initiate a login flow which will render the login view for you - given you gave it valid parameters.

Get Instagram login ID through API auth login

I'm trying to make a check for a specific user logging into Instagram and approving an app I've created. Is this possible?
Example flow :
User comes to my app
User clicks login/authenticate via Instagram
User logs in (or check is made if user is logged in via Instagram)
User is redirected to my app's callback URI.
When the user gets back to my app I would like to be able to check which user has authenticated - is this possible? At present I'm only able to get an access token.
Thanks for any help.
I've actually solved this by using the server-side flow mentioned in the API documentation (http://instagram.com/developer/authentication/) which gives me back a response including the details of the user logged in if following the extra step (code->access_code application, etc).
I also figured out what you mention above too, so both ways are good.
Thanks for you help.
The information is not directly returned to you in the OAuth process, but once you have the access token you can load user information using the https://api.instagram.com/v1/users/self/?access_token=XXXX endpoint. That will give you data about the currently logged in user (including ID and username)

MVC Simplemembership I cannot get the userID after logging a user in via OAuth

So I am in the process of implementing a Facebook login via MVC 4 simplemembership oAuth provider.
Registering and signing in the user has worked well. However after signing in a user using oAth, I am unable to get the UserId of the authenticated user. I can see that the UserId exists in the membership_oauth table and it relates to the UserId in the UserProfile table.
Normally I would fetch it using WebSecurity.CurrentUserId but there does not seem to be a method for getting this when using OAuthWebSecurity. When I try, WebSecurity.CurrentUserId I get "an instance of the object has not been instantiated", error.
Does anybody know how to get this information?
Much appreciated!
I assume you're trying to get the userID in in a controller. Have you tried:
int currentUserId = (int) Membership.GetUser().ProviderUserKey;
I can't tell you if this works with Facebook or not, but it works with Google Auth. for me.
You should also add [InitializeSimpleMembership] on top of controller class if you use another controller than AccountController.
Check this: Get UserId (int) in new MVC4 application
EDIT:
Check this method int GetUserIdFromOAuth(string provider, string providerUserId) and try something like:
SimpleMembershipProvider provider = (SimpleMembershipProvider) Membership.Provider;
int id = provider.GetUserIdFromOAuth("you_know_the_provider", "you_can_get_the_provider_user_id")
Also, the guy in this question:
OAuth and SimpleMembership - how to retrieve ProviderUserId from webpages_OAuthMembership table
is complaining about the opposite of your problem: he wants the ProviderUserKey but keeps getting the UserID instead.

Manual login user with devise

Can anyone give an example or link to tutorial how can be implemented manual signin for users and get session_id.
I am porting an application from Rails 2 to Rails 3, that used before RestAuthentication. The new app uses devise, and I already managed to fix the sign-in/sign-out for admins. The application has one more model (users) that need to be authenticated.
I need to get session_id in order to pass it in the response, because the client is not browser, but mobile device.
Any links, ideas and examples are welcome. Thanks in advance!
I used token id instead of session id. The token is re-generated each time when the session is expired or user log-outs.

how to get logged in user name from window service

how to get logged in user name from window service. when i do the same thing using Environment.UserName i get username as "System".
thanks
Arvind
You get System because your service runs under the System account.
There is an article on codeproject that discusses the same thing .. check it out http://www.codeproject.com/KB/vb/Windows_Service.aspx
System.Diagnostics.Process[] objArrProcess = System.Diagnostics.Process.GetProcessesByName("explorer");
string strCurrentUserName = objArrProcess[0].StartInfo.EnvironmentVariables["username"];
This works for me.
Check this link which talks about getting current loggedin user from window service -
http://www.pcreview.co.uk/forums/thread-3460184.php
Taken from above link itself -
There can be 0 or more current logged in users. If you want all of the 0 or
1 users who are currently logged in at the console then P/Invoke to
WTSGetActiveConsoleSessionId and WTSQuerySessionInformation. If you want
all of the users then you'll need to call WTSQuerySessionInformation in a
loop.