Pass cookie to WebBrowser in Windows Phone 8 - c#

I am currently developing an app that uses a public API. After performing the login procedure with that API, I get a cookie that I store in my app. I need to pass this cookie with every API call, that I request. So far so good.
Now unfortunately this API doesn't give me acces to all features of the service. What I want to do is giving the users of my app a button, which open a WebBrowser for that specific features. The problem is, that the user is, of course, not logged in in that WebBrowser.
What I found out on my PC is, that the login-cookie, that I get from the API, would actually work for the website itself as well. So what I want to do is: When the user clicks on the button, it opens the WebBrowser and passes the login cookie I already have to the WebBrowser, so the user is already logged in and can use the feature. Is there any solution for that problem? I couldn't an answer for that.
Cheers! :)

You can only set cookies from invoking javascript on the page when loading is completed.
Windows Phone WebBrowser set cookies

Related

Get Token from web site and pass it back to WPF

I need information about how am I suppose to get a token from an external browser passed to my WPF application.
The user will click a button on my WPF which will launch a chrome browser, then the user will log in and after they do, I have to get the access_token passed back to my WPF.
Something like google authentication, when you sign in to a desktop application using google, you get a new tab on your browser, you sign in and then you return to the web application to find it signed in automatically.
I want to build something like this, if possible!
There is a google sample app online that you can reference for how to do this in WPF.
https://github.com/googlesamples/oauth-apps-for-windows
Specifically, the WPF app is the one named 'OAuthDesktopApp'.

C# Windows Forms Spotify API User Authorization

I'm trying to authorize a spotify user in my windows forms application. I am able to make a GET call to the web API, and I get a response back that is HTML. When loaded into the browser, this HTML is a login page, but my question is two parts.
1) What would be the best way to display this login page. Obviously if I could launch the browser and have it return the authorization code somehow, that would be best, which brings me to my second question.
2) How would I get the authorization code from the browser when I launch the login screen? I can't see a way that my forms application would be able to receive any information after the login screen is launched. Sorry if this seems obvious.
I figured it out, the URL I was using was not meant to be requested from, but to have the user navigate to in their browser. I basically just put the link in my application as a button and it would launch in chrome. Once the user logs in, I used http://httpbin.org/get to display the authentication code and just copied the code into my app as a temporary fix. Obviously this is not ready for release, and I am still working out how to get the code from the redirect url to my application, but it's a step in the right direction!
1) You can display a web browser inside your form to do the login part.
2) Browsers like Chrome can't return values. You could look at the data sent / received from your browser and search for an authentication token or something like that

Set cookie in default browser using c# desktop application

I am trying to open a url which needs username/psw combination from a desktop app. Desktop app already has an authentication mechanism. What i want is if someone tries to open the url then i'll pass the access token from desktop app to the web, so that user don't need to login again.
One crude way to do this is to check the default browser using registry and depending on the default browser set the cookie in their local sqllite file(for chrome and firefox). But this approach doesn't seems to be the good one.
Is there any other way to do this ?
The most crude way would be to pass it as a query string parameter. This may not be ideal as you might not want it to show, although you could have the target site do a quick redirect after authenticating. You also want to be sure to only do this over HTTPS.
Another way if you'd prefer to POST the data would be to write out a local HTML file with a form that auto submits on load. Have the access token in a hidden field on the form. This would allow you to do a POST.
In either case, you can launch a browser to a specific page using Process.Start("https://example.com/mypage").

Facebook Authentication in Background - C# sdk

I am developing a windows phone app using facebook c# sdk. I created a login page to authenticate the user and it also working well. But my problem is, next time when the user open the app, it should be navigated to main page and do the authentication work in background. Is there anyway to do this??
I used navigatedto override method to "redirect the user into the mainpage". I dont know how to authenticate the user in background. Help plss..
save token (received from fb) in ur isolated storage & check if it invalid in ur HomePage and so accordingly navigate to Login (if invalid)

Delete Cookies from Webbrowser control in wp7

I have a problem with facebook and google logout. My scenario is when user first time login with facebook or google for particular site.(using clint api, it will redirect to their own web browser). then it will show the login page . after successfully logout if again login with facebook or google i m trying it's not showing the login page , it directly shows the login success message.(because webbrowser history already there, and i am not able to delete the history) so in this situation multiple user can't login with facebook or google.
have anyone idea? how to solve this problem?
On WP7 you'll have to use InvokeScript and javascript to logout and/or get rid of cookies required by different services like FB and Google. Fiddler comes in handy for this.
If I remember correctly, for Google you'll have to watch for specific URL's and cancel navigation, run InvokeScript and continue navigation.
I worked on a project that accessed different providers and this was the solution we were able to get working.
On WP8 there is a method to clear cookies.
Try finding out if there is an OAuth or API url for logging the user out such as
m.facebook.com/logout.php?confirm=1&next=(url encoded login page)
to navigate the user to.

Categories

Resources