How to complete login page using okttp - http

Knowing a login API, how to use okhttp to build a login page
I can build the layout of xml, but I can't do it in the activity and other operations

Related

javafx Do a http post request in webenigne

I have googled around but unfortunately I didnt find what I am looking for. For a small application I am working on, I am using a Webview. In this webview I would like to load a page where I would like to do the login - which is done using a http post request of type
--> "Content-Type", "multipart/form-data;boundary="+boundary; <--
Using a HttpURLConnection I can use a DataOutputStream passing the login data to the server. But how would I do such a login with on a WebView's WebEngine??
Best Regards
Load the page in the WebEngine and have the user enter their login credentials and submit them just like they would in a standard browser. The WebEngine will do the multi-part form data post the server to appropriately log the user in.
If you need to automate this process on behalf of the user (i.e. because you have authentication credentials stored elsewhere for a kind of single sign on app), then, once the engine has fully loaded the login page, you can make webEngine.executeScript calls to populate the form login fields on the page and trigger the submission of the login information to the server (probably by triggering a click event on the login form submission button).
You can also use this routine to execute jQuery on the document to do the form filling and trigger the submission if you prefer to work with that API.

Infinite redirect loop after facebook authenication in asp.net

I am trying to use facebook authentication on my asp.net application.
I am using Facebook JavaScript SDK calls for this purpose.
In my case, I call the facebook javascript SDK from my normal Default.aspx page, then it authenticates, then sends the uid and access token to a data handler I created. In the datahandler I am creating the session. Then I redirect to the parent page from the data handler.
All this works fine when I am using a normal ASPX page (not any usercontrol). But when I use the same logic inside any user control and call the user control from the default.aspx page (in this case the facebook authentication and facebook login button is inside my user control), after authentication and calling data handler, when I redirect to my default.aspx from my datahandler, this cycle goes on infinitely.
My page keeps on authenticating and keeps on calling the datahandler when then again calls the default.aspx
Please suggest any good approach where I can authenticate the user and come back to my default.aspc when it has the user control.
I created my facebook authentication logic (used only the javascript and datahandler logic) by following this tutorial:
http://csharpsdk.org/docs/web/getting-started
I can attach the code also if requested.

Facebook Connect Server-Side GetLoginStatus using ASP.NET C#

I am currently using the Facebook Javascript SDK and the Facebook C# SDK (soley for retrieving user graph objects).
Everything so far is going great except for the following scenario:
User logs into Facebook
User opens a new browser window and visits my
site
Using the Javascript SDK, I can use the FB.getLoginStatus method to determine if they are connected or not (which they are in this scenario as I have previously authorized my site/app for the facebook login).
However, I need to be able to detect upon the homepage of my site loading for the first time, ideally server-side, if we are in this 'connected' state, and if so, render some different content to screen (logged in vs not logged in).
I can't currently see a server-side method in the Facebook C# SDK that enables me to do the equivalent of FB.getLoginStatus (clientside).
I should point out that any subsequent changes to the users loginstatus is handled via subscribing to the auth.authResponseChange event and all is working fine there, but its the first time page load when the user first hits the site that's the problem.
There isn't a way to do this on the server with any Facebook SDK. You must detect the user's status with the Facebook Javascript SDK. The reason for this is because this information is stored in cookies that are either only readable by facebook.com or that are on you domain, but were set by Facebook and should not be parsed by your app.
You can parse the cookies on your domain if you like, but it isn't recommended because Facebook considers those cookies to be an internal implementation detail and does not guarantee their contents. They could change at any time and break your app.

Forms Authentication issue with WebBrowser Class in asp.net

I am developing a site and in this site i m building a functionality to capture a screen shot of a page. In my site i am using forms authentication.now first of all.
So when user login to the website he/she has to enter the credentials and then go to their profile page.
So now i am just creating a thumbnail of the user profile page using WebBrowser Control but the problem is , i m using forms authentication and it's always capture the login forms page because of forms authentication.
So Please help me ASAP.
In that case you will need to perform login programtically for forms authentication. Here is the piece of code which will be required.
FormsAuthentication.SetAuthCookie(UserName, false);
And here is more info
http://weblogs.asp.net/joseguay/archive/2009/03/23/the-asp-net-capsule-2-login-programmatically-with-forms-authentication.aspx.
However, be aware that the code you are using for creation of screenshot might not go well with it. So take care of this. These posts might help you in that case Send credentials to WebBrowser
You have to simulate forms authentication via WebBrowser control - essentially, use document object model (Document property) to locate user name/password input boxes, set their values and trigger submit (either inject java-script to do form submit OR use DOM to simulate login button click).
IMO, better way would be to use WebRequest (HttpWebRequest) to simulate the POST to login page to do authentication and then issue request to user profile page. Get the page html(from response) and load it in Web Browser control using DocumentText property.
In case, you have control over the server site, you may modify user profile page to allow un-authenticated access over certain requests (for example, from local machine or specified IP etc).

Open protected web page passing in credentials programmatically

I have code examples from some of my previous work that help me to post form values to a web page (login credentials) and retrieve the text from that page. Now I want to pass in form values (login credentials again) but actually open that web page in a browser given those credentials.
How do I do that? I'm not doing anything nefarious. In our CRM app (home-grown as it is), I want to create a link button that opens our web site's protected products page given the user's credentials (based on the user's login credentials). Normally, I'd copy the user's credentials in our login page which then takes me to the products page. I'm trying to do this now by just clicking a link button.
Any suggestions?
How are you launching the browser? Is this an internal network app? If so, I would recommend using Windows Authentication for your ASP.NET app, and then you don't have to worry about passing credentials. If you can't do that, then you'll probably have to pass the credentials on the querystring generated by your CRM app. Obviously, this is a huge security risk. But the next step would be to perform your internal authentication and then call FormsAuthencation.RedirectFromLoginPage or FormsAuthentication.SetAuthCookie().

Resources