hi i am connecting to facebook using the following code it work fine for my two account one is gmail and another one is yahoo but it is only working on that accounts not log in on the other accounts of the gmail,yahoo,hotmail i check every acccount that i have every time onautherror come why ? what i am doing wrong is my code is wrong can any one tell me plz
Jid jidUser = new Jid(txtBoxUserName.Text);
xmppCon.ConnectServer = jidUser.Server;
xmppCon.Username = jidUser.User;
xmppCon.Server = "chat.facebook.com";
xmppCon.Port = 5222;
xmppCon.Password = txtBoxPassword.Text;
xmppCon.AutoResolveConnectServer = true;
xmppCon.Open();
Facebook doesn't allow the username/password XMPP authentication anymore.
You can only login using the X_FACEBOOK_PLATFORM SASL mechanism.
See:
http://developers.facebook.com/blog/post/2011/09/09/platform-updates--operation-developer-love/
So for Facebook use X_FACEBOOK_PLATFORM SASL auth in agsXMPP and it will work fine.
Related
guys, actually I have a problem in my code and the redirection feature in my router, after I wrote the code which able to find the form and login into the router I faced a problem that after the login using the login.cgi the router redirects the link into something like http://192.168.1.2/index.asp;session_id=2dfa2490ad2e26a3d073edfdae7d0f45
what I could understand that it shows the session id in the link and I need help to make my code understands and gets the link I tried many times using
browser.get_url() but it shows http://192.168.1.2/login.cgi
thank you guys
def wifi_pass_changer():
username = 'admin'
password = 'admin'
url = "http://192.168.1.2/"
browser = mechanicalsoup.StatefulBrowser()
browser.open(url)
browser.select_form('form[action="login.cgi"]')
browser["http_username"] = username
browser["http_passwd"] = password
response = browser.submit_selected()
I am using "IdentityServer3 - IdentityManager - MembershipReboot" in my project for User Management, Authentication & Resources Authorization.
I started from below sample and have gone good for creating users, authenticating them via /connect/token api and authorizing resources.
https://github.com/thinktecture/Thinktecture.IdentityServer.v3.Samples/tree/master/source/MembershipReboot
A brief architecture for my solution is
MySql as database. Communication via MembershipReboot.EF to MembershipReboot.
The client project is developed using html + angularjs.
Resources APIs are developed using Nancy & hosted on Owin+Katana in a seperate project.
Authentication Services(IdSvr+IdMgr+MR) are hosted in a seperate project.
Now I want to create a simple button/link clicking on which leads me to facebook login. The functionality of this button should be same as defined in IDSvr default login page's(https://localhost:44333/core/login?signin=4f909a877cc465afd26d72f60ec08f51) "Facebook button".
I have tried googled internet a lot but none of cases are matching my scenario.
I even tried to replicate the request-response behaviour of default IdSvr facebook login but that does not work as cookies are not being saved on end client.
Also i tried to hit "https://localhost:44333/core/signin-facebook" and getting response as HTTP/1.1 500 Internal Server Error from server. So i think might be I am somewhere wrong in setting facebook options in IdSrv project.
So if someone can just provide me a single IdSvr API to connect or tell me how to config Id Svr so that mapping a url can redirect it to facebook login. Or can tell me that where I am wrong in setting facebook authentication options in IdSrv.
A short and simple answer for my question is that I was looking for url.
https://localhost:44333/connect/authorize?client_id=implicitclient&response_type=token&scope=read&redirect_uri=http://localhost:8088/login/auth&nonce=random_nonce&acr_values=idp%3AFacebook&response_mode=form_post
Read further if you want to get better idea about this url
After lots of Hit&Trial & Study efforts, I have got solution for this. Well I think root cause for this problem was that sudden new technical things(Owin, Katana, OAuth, IdentityServer, IdentityManagement, MembershipReboot, Owin Facebook) and a meager time to understand them all.
I would advice folks that whoever is in same situation as me then first get an idea about OAuth. I found below link as a short and good one.
http://tutorials.jenkov.com/oauth2/index.html
After this I learnt that in our scenario we are dealing with two applications and hence two authentication.
For connecting User to Facebook. We created an app on developers.facebook.com
For connecting User to IdentityServer. We created a client in Clients.cs file on AuthenticationServices project.
So now here is the final solution.
localhost:44333 where AuthenticationService is running
locahost:8088 where FrontEnd services are running which iscalling AuthenticationService .
1. Create client app in AuthenticationServices as below
new Client
{
ClientName = "Implicit Clients",
Enabled = true,
ClientId = "implicitclient",
ClientSecrets = new List<ClientSecret>{
new ClientSecret("secret".Sha256())
},
Flow = Flows.Implicit,
RequireConsent = true,
AllowRememberConsent = true,
RedirectUris = new List<string>
{
"http://localhost:8088/login/auth" //This should be redirect url you want to hit after your app(not facebook app) redirects.
},
ScopeRestrictions = new List<string>
{
Constants.StandardScopes.OpenId,
Constants.StandardScopes.Profile,
Constants.StandardScopes.Email,
"read",
"write",
},
//SubjectType = SubjectTypes.Global,
AccessTokenType = AccessTokenType.Jwt,
IdentityTokenLifetime = 360,
AccessTokenLifetime = 360,
},
2 Create Authorize URL as below
var client = new OAuth2Client(new Uri("https://localhost:44333/core/connect/authorize"));
var startUrl = client.CreateAuthorizeUrl(
clientId: "implicitclient",
responseType: "token",
scope: "read",
redirectUri: "http://localhost:8088/login/auth",
nonce: "random_nonce",
responseMode: "form_post",
acrValues: "idp:Facebook");
The facebook app after successful authorization will redirect default to http://localhost:44333/signin-facebook. So no need to do any changes there.
Finally on http://localhost:8088/login/auth you will get access_token(+ few other parameters) after successful authentication. Here onwards you can use this token to access resources from Resources server.
I'm a newbie to app development. I am building a Windows Phone 8.1 app and have followed the tutorial here: http://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-dotnet-backend-windows-store-dotnet-get-started-users-preview/ to add authentication using Facebook. Everything seems to work fine, except that every now and again it appears to stop bringing back any data from my Azure database. Further investigation revealed that the UserId that is being shown from the code below, changes periodically (although I can't quite work out how often it changes).
// Define a member variable for storing the signed-in user.
private MobileServiceUser user;
...
var provider = "Facebook";
...
// Login with the identity provider.
user = await App.MobileService.LoginAsync(provider);
// Create and store the user credentials.
credential = new PasswordCredential(provider,
user.UserId, user.MobileServiceAuthenticationToken);
vault.Add(credential);
...
message = string.Format("You are now logged in - {0}", user.UserId);
var dialog = new MessageDialog(message);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
This code is identical to the code in the tutorial. The Facebook app settings (on the Facebook developers site) confirm that I am using v2.3 of their API so I should be getting app-scoped UserIds back. I have only ever logged in with one Facebook account, so I would expect the UserId to be the same each time, but they're not. The UserId is prefaced with 'sid:', which someone on the Facebook developers group on Facebook itself says stands for Session ID, which they would expect to change, but if that's the case, I can't work out where to get the actual UserId from that I can then store in my database and do useful things with. I'm sure I must be doing something basic wrong, but I have spent hours Googling this and cannot (unusually) find an answer.
Any help would be greatly appreciated.
Thanks!
So dug deeper. This is how Mobile Apps work (I was thinking from a Mobile Services perspective). The issue here is that the Gateway doesn't provide static SIDs, which is what User.userId provides. The work around to this is listed in the migration doc.
You can only get the Facebook AppId on the server.
ServiceUser user = (ServiceUser) this.User;
FacebookCredentials creds = (await user.GetIdentitiesAsync()).OfType< FacebookCredentials >().FirstOrDefault();
string mobileServicesUserId = creds.Provider + ":" + creds.UserId;
You should note, that this Id is directly connected with your Facebook App registration. If you ever want to migrate your App to a new Facebook App, you'd have to migrate them. You can also use the Facebook AppId to look up the user's global facebook Id via the Facebook Graph API, which you could use between applications. If you don't see yourself using multiple apps, etc., you can use the Facebook AppId just fine.
Hard to tell what's going on to cause you to use a SID instead of the Faceboook token (which like Facebook:10153...).
It may be faster to rip out the code and reimplement the Auth GetStarted. Maybe you missed a step or misconfigured something along the way. If you have the code hosted on github, I can try to take a look.
Another thing you can do is to not trust the user to give you their User id when you save it to a table. On your insert function, you can add it there.
function insert(item, user, request) {
item.id = user.userId;
request.execute();
}
That should, theoretically, be a valid Facebook token. Let me know if that doesn't work; can dig deeper.
I am trying to understand how I should configure a web site (ASP.Net) that need to pass the user credential and get some mail things
I get different kind of errors depending on the app pool configure,
What is the complete way to do it? I mean code + Configuration ;o)
I don't want to write the user and password but get them through the windows authentication
Thanks
code:
Service = new ExchangeService(ExchangeVersion.Exchange2010_SP2)
{
Url =
new Uri(
"https://xxx/yyy.asmx"),
//UseDefaultCredentials = true doesnt help
};
var view = new ItemView(1820);
// Find the first email message in the Inbox that has attachments. This results
FindItemsResults<Item> results = Service.FindItems(folderName, view);
//Here I get the error 401
Take a look at Get started with EWS Managed API client applications, it covers the basics to get you up and rolling. Note that when you use UseDefaultCredentials, you have to be on a domain joined machine, with the user logged in, and you must be targeting an on-prem server. We tested that scenario out and the following code works in that scenario.
using System;
using Microsoft.Exchange.WebServices.Data;
namespace HelloWorld
{
class Program
{
static void Main()
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
service.UseDefaultCredentials = true;
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
//Replace the URL below with your own, but using AutoDiscover is recommended instead
service.Url = new Uri("https://computer.domain.contoso.com/EWS/Exchange.asmx");
FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Inbox,
new ItemView(1));
}
}
}
If that doesn't work for you, then you might want to try using impersonation. See this thread, where I think they've got a similar situation . More information about impersonation is on MSDN: Impersonation and EWS in Exchange.
I have an app with a local login system. What I am trying to do is allow the user to connect their facebook account to their account. I am using Zend Auth for my main local login and a facebook auth by Michael Krotscheck.
I can connect with facebook fine but because I am using Zend_Auth the facebook data is over writing the main local login storage. All I need is the users email and facebook id and insert them into my users table.
The code below shows how it all works, I do not know another alternative than using Zend Auth for the facebook login. Anybody had the same issues? Advice would be very helpful.
$auth = Zend_Auth::getInstance();
$adapter = $this->_getFacebookAdapter();
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$toStore = array('identity' => $auth->getIdentity());
// for facebook
$msgs = $result->getMessages();
$toStore['properties'] = (array) $msgs['user'];
$toStore['provider'] = "facebook";
$auth->getStorage()->write($toStore);
$this->_helper->FlashMessenger('Successful authentication');
//return $this->_redirect('/index/index');
// Check if the User is in our dB
//$users = new My_Model_Users();
//$userTrue = $users->checkUserExists($userId,$providerName);
Zend_Debug::dump($toStore);
Zend_Debug::dump($this->_helper->user());
} else {
$this->_helper->FlashMessenger('Failed authentication');
$this->_helper->FlashMessenger($result->getMessages());
//return $this->_redirect('/index/index');
}
J
After more trawling stackoverflow I found a solution.
Multiple Instances (2) of Zend_Auth
Basically created my own Auth class and removed the singleton pattern in Zend_Auth, this allowed me to create another instance.
J