The login page is displaying in the team's tab on the browser. Now the issue is on the login prompt it tries to open iframe which is not allowed in the one another iframe in the team's tab. It works fine on a normal browser page but having an issue only in the team's tab on the browser.
The error which we are getting is like: Refused to display 'https://login.microsoftonline.com/' in a frame because it set 'X-Frame-Options' to 'deny'.
Details of Code:
Language: Python
Architecture: Flask Apis for rendering pages
Issue: iframe not working in team's browser tab.
Authentication: MSGraph.Authorization
Could you please help with this?
I presume you're using MSAL 2.0 (recommended). If so, there are two auth flows - redirect and popup. In Teams, it's a little different because Teams itself is actually launching the popup for the auth flow. As a result, even though it involves a popup, this popup will launch to your own auth page, and you end up doing redirect flow from inside there.
Here's a sample I put together for Tab SSO that should help (it's not python, but hopefully the node/Dotnet examples will be good enough guidance): https://github.com/pnp/teams-dev-samples/tree/master/samples/tab-sso
Related
I was using Selenium Python to log in to Instagram and open some pages. It worked fine, but after two days the Instagram started sending the message "CSRF token missing or incorrect". And now I can't even log in with my script or manually to any accounts and with any browsers such as Chrome or FireFox on my laptop.
I'm not sending any cookies with my Selenium. And most of the search results are about Django which I'm not using.
I erased the cookies, but it it didn't work.
I tried to change my IP address to make sure if I'm banned from Instagram, but it didn't work.
I tried to check for the scrf-token in my URL with Selenium and sending it to the driver, but it didn't work.
I'm not sure if the solution is within the code, because now I can't log in even manually, so maybe there must be a problem with my system settings or from Instagram side.
Can I fix this with Selenium? Or how can I fix this?
One liner to run in JS console in your browser to fix CSRF token issue:
n=new Date;t=n.getTime();et=t+36E9;n.setTime(et);document.cookie='csrftoken='+document.body.innerHTML.split('csrf_token')[1].split('\\"')[2]+';path=\;domain=.instagram.com;expires='+n.toUTCString();
Open JS console, copy paste it, press enter. Reload the page and try to login again.
This js snippet will find CSRF token in page source and create cookie for you.
Open your Chrome browser developer tools, and then go to the login page of Instagram. In the network tab, find the request that goes like this: https://www.instagram.com/
Click on the request and in the response tab, press Ctrl + F and search for csrf_token. Copy the value of csrf, and go to the application tab. In the storage section, click on cookies and insert a cookie with the csrftoken name. Paste the value and make it secure. Now fill the login form and press Enter.
I had the same problem. I used a VPN to connect to the US, and there wasn't any "CSRF token missing" message after that.
As mentioned #350D this way probably work, but it doesn't work for me.
I had to remove my local storage (from inspect).
and if you have two step verification, you remove it temporarily.
Firefox
Open the Firefox Options menu.
On the left, select Privacy & Security.
Under Cookies and Site Data click on Manage Exceptions.
Copy and paste "https://example.com" and click Allow.
Click Save Changes.
Next, click on Manage Data.
Search for todoist and select Remove All Shown.
Click Save Changes and confirm in the pop-up window by clicking Remove.
Reload Firefox and log into Todoist.
Chrome
Open Chrome Settings.
In the Privacy and security section, click Cookies and other site data.
Scroll down to Sites that can always use cookies and click Add.
Copy and paste "[*.]example.com" and click Add.
Click See all cookies and site data, search for todoist, and delete all Todoist-related entries.
Reload Chrome and log into Todoist.
So I'm automating Exchange mailbox creation with our email hosted by a 3rd party. They use a software called Hosting Controller which gives me the ability to create new mailboxes. Except it's all manual, So Im working on a Python+Selenium script to automate this process.
I'm hitting a roadblock where I'm unable to identify this popup so I can manipulate it. I believe it's JQuery but the
Alert = alert.switch_to.alert()
Refuses to work.. I get tracebacks. I then examined switch_to.element/frame/window but I couldn't get any of those to work.
I'm very new to this stuff being this is only the second Python script I've ever tried outside of training coursework.
Here is a short video on what I'm talking about: https://streamable.com/3dx3z5
So, from looking at your video, the pop-up form that you're seeing is a modal. Without having access to HostingController.com or login credentials, I cannot find the xpath for you. So, what you will need to do is look at the HTML source using the Browser's Dev Tools / DOM ( F12 if you are using the new Chromium Edge or Google Chrome itself ) and check to see if the modal is displaying. I submitted an answer to a question in another thread regarding pop-up modal ( here ). I hope this guidance helps.
TO be specific, I want to make a Python web crawler that uses a plugin on Chrome called "Adapt Prospector," which allows you to find people's emails once you land on their linkedin page. Here is an example of what I mean:
https://i.postimg.cc/DyxWzxWJ/example_pic.png
You first go on the person's linkedin page, then click the plugin logo on Chrome's extension bar, then the plugin will show you the linkedin profile's email (if there is one).
Basically, I want to create a program that goes to a person's linkedin page, then clicks the plugin logo on the extension bar, then scrapes the data the plugin is showing.
I definitely know how to do the first part, but I'm not sure if the last 2 parts are possible. I searched extensively on if its possible to make a web scraper that uses a plugin, but I haven't found any "yes" or "no" answers to this.
You can try to :
Find which request gives the informations you need using the Network tab of your browser console. Then do the same request with your favorite python library
Use selenium which will behave more or less like your browser, go to the person's linkedin page, and the informations should be somewhere in the page, maybe hidden.
Your plugin just reorganize the informations it finds on the page. Linkedin provides to your browser all the informations you need.
EDIT : Using Extensions with Selenium (Python) you can try this but I think that selenium without the extension will do fine as well
I am trying to implement Facebook Login in my Canvas App using "Manually Build a Login Flow". To implement this successfully, I have to redirect to the Facebook authentication url with target = "_top" parameter, basically the following redirect:
Redirect here
I know we can use self.redirect({url}) to perform redirects in GAE, but am unable to find how can we set up a target as in the above html code.
Please help me out.
Target just defines where the browser window will open the page. If the <a> (hereafter "link") is in an iframe, the browser will open the link in the highest level of the frameset (as a regular page). This is important for oauth links since iframes have certain restrictions which break the needed flow of requests.
You'll be fine doing a regular redirect, assuming that the link the user clicked to get to the redirecting handler was itself an <a> element that is either not running in an iframe or has target="_top" if so.
I am using Python and a javascript or php sdk.
To obtain the access_token - I follow the steps indicated on the docs page (https://developers.facebook.com/docs/authentication/). I pass the redirect url to dialog/oauth and obtained the access_token. Once this is done, all output html being sent back to the browser gets rendered into to a new page, leaving the facebook iframe/canvas. (fyi, all output is done thru the usual 'self.response.out.write' function call).
Seems the PHP sdk hides this and I can't find a way to get : http://www.facebook.com/dialog/oauth?client_id=%s&redirect_uri=%s" dialog to send the output from the redirected url to the iframe/canvas that triggered the application. This is a 'Page Tab' app (not a 'App on Facebook') so have set the "Page Tab Name" and "Page Tab Url" on the basic apps config page.
I have not implemented session yet and I am wondering if that is necessary to pass the iframe target as a state variable and have it passed back along with the redirect to the uri.
I have searched many posts/etc and no luck and any help would be much appreciated !!
Tab Page Application undocumented steps :
The confusing part is the CANVAS_PAGE_URL in the example. This needs to be the web-hosted app URL (e.g. https://www.appname.appspot.com/).. This not clearly defined..
If access_token and the user_id is not found on the signed_request an auth dialog needs to be done (as per the page documentation). This needs to be done thru the script top.location.ref to endure that it launches as a dialog. This goes to a new page overwriting the canvas (or the fan-page) that triggered the app.
When the user allows the permissions on the app, the app is called thru the tab-page-canvas-url?code=".....". At this point, a redirect needs to be done (which is not documented anywhere. I had to look at the php sdk code to figure this out (fbmain.php line 17) (redirect() in python and header() php). The redirect needs to take the url for the app on the fan page : http://www.facebook.com/FAN_PAGE_NAME?sk=app_nnnnnnn
It took many hours of research and digging to understand this and hope it helps (I see a lot of questions raised around page breaking out of the iframe/canvas) and the basic problem is the extra redirect step that FB does not document anywhere...
(mail me and I am happy to share python code that is now all working nicely)
It is stated elsewhere, but to make clear: the reason your app breaks out of facebook is because the authentication dialogs get away from the original apps.facebook.com url.
This may only happen with extended permissions as the new permissions screen is two pages instead of one.
Once the authorization process is complete, the browser is redirected to the fully qualified app url on your server.
The "fix" is to send the browser back to the Facebook app using it's http://apps.facebook.com/appname address.
[that doesn't seem like good "flow" to most people, but that is how it is right now. I think there may be a different route by using the "Authenticated Referrals" on the "Auth Dialog" page of the apps, but haven't used it yet]
I use the PHP SDK and here is what I do:
Check for the "state" request parameter when your redirct_url is called after authorization. Some people had suggested using the "code" parameter, but I do not see it being returned.
''
// after completing the first authorization, the redirect url may send users away from Facebook to the redirect url itself.
//This php code redirects them back to the app page
if (isset($_GET['state'])){ header("Location: http://apps.facebook.com/appname']); exit; }
If you know a better way, please let me know!