I want to let users to login their instagrams and see their statistics in my app. I created a webview inside to help them login. But in the app, I am getting the cookie differently.
With:
onPageFinished: (String url) async {
String sourceCode = await controller
.evaluateJavascript("document.body.outerHTML");
if (url == "https://www.instagram.com/" &&
sourceCode.contains("window._sharedData =")) {
String cookies =
await controller.evaluateJavascript("document.cookie");
//new intent
print(cookies);
setState(() {
visibility = false;
});
}
},
I am checking that if the redirection is going through instagram.com, login is successful. After that with the "document.cookie", I am getting the cookie.
The problem is with "document.cookie", I am getting a short cookie that is not useful for queries on instagram.
In the browser it has a cookie starting with : ig_did (it is a long one), but in my app, I have a cookie starting with : "mid=".
I am thinking about how to get or generate that long cookie, if I cant, I am not able to request end points.
Thanks..
Problem is solved with using webview_cookie_manager 2.0.1; document.cookie is not enough to get all the cookies from the url.