I am using TableauServerClient (0.8) in a Python (3.7.1) script to download a view as .csv from Tableau server (2019.1.3 (20191.19.0417.1429) 64-bit Windows) onto my local machine. My code works for most of the views but for some views, I am getting following error:
tableauserverclient.server.endpoint.exceptions.ServerResponseError:
400081: Bad Request
There was a problem querying the data for view 'xyz'
Has someone faced this issue in the past? Any thoughts?
I was facing a similar error & neither the documentation of Python API nor the REST API had any info about this issue. ( I couldn't even find the API response error code in either)
But after a long search, I stumbled upon a suggestion by the user 'gaoang2148' in this thread.
For me, the error was occurring because a few data sources in my workbook were missing connection credentials ( The credentials were missing after I published an update from Tableau Desktop). Once I embedded the credentials for each data source, the code was working fine again. i was able to pull & download data from tableau views via API.
When I have run into this, it’s been on newly published views. I believe it has to do with Tableau's behind the scenes managing of views and/or data in the repository. Sometimes it takes an hour or two for a new view that's been published to query properly from TSC. Manually navigating to the view in browser also might force the view to be processed, but that could've been coincidence when it's happened to me. It usually resolves itself within an hour.
Related
Previously, this bit of python code worked:
from google.cloud import bigquery
from google_auth_oauthlib import flow
appflow = flow.InstalledAppFlow.from_client_secrets_file(
"credentials.json", scopes=["https://www.googleapis.com/auth/bigquery"])
appflow.run_console()
However, I now get an Error 400: invalid_request message when it directs me to new browser. The details of the error are:
Error 400: invalid_request
The out-of-band (OOB) flow has been blocked in order to keep users secure. Follow the Out-of-Band (OOB) flow migration guide linked in the developer docs below to migrate your app to an alternative method.
Request details: redirect_uri=urn:ietf:wg:oauth:2.0:oob
I know that Google has updated some of its policies in this space in recent months, but I've tried a lot of different things and it won't work (most that result in a uri_mismatch error).
As the credentials are for a Desktop App, I can't add specific URIs in the console like I would for others e.g. Web app. However, I can see in the JSON the redirect uri is set to "http://localhost"
I've tried manually updating the redirect uri (e.g. by adding '8080') in the json file, as outlined at the very bottom of this page. See also this and this article from Google but am getting the same invalid_request error.
This stack overflow answer gives a hacky suggestion, although it didn't work for me.
How do I 'update' my auth method to get it to work now? Ideally the browser pop-up should give me an authentication code that I can manually copy back into the python notebook.
I followed the steps in this tutorial to enable SSO with Azure Active Directory for the admin portion (to start) of my Django app:
https://django-microsoft-auth.readthedocs.io/en/latest/usage.html
Navigating to /admin yields this page, which is good:
Clicking Microsoft brings up this new window:
The important error seems to be:
AADSTS90102: 'redirect_uri' value must be a valid absolute URI.
In this window, I used the browser console and found that a GET request was being made like this:
https://login.microsoftonline.com/50ce...90ac7/oauth2/v2.0/authorize?response_type=code&client_id=f4...27&redirect_uri=https,https://example.org/microsoft/auth-callback/&s...
Note the redirect_uri=https,https://.... It seems like that leading "https," is superfluous and is causing the problem. Any ideas where that could be coming from?
In my Azure app, the redirect URI is set to https://example.org/microsoft/auth-callback/:
I'm using Python 3.9.6, Django 3.2, django-microsoft-auth 2.4.0, NGINX 1.18.0, uvicorn 0.14.0
I've searched for help on this and haven't found anything relevant to my situation. Thanks in advance!
Based on the SO Thread Reference.
Use http as the redirect URI instead of https to resolve the issue in most cases.
use
http://localhost:8080/microsoft/auth-callback/
Instead of
https://localhost:8080/microsoft/auth-callback/
If there is a option,
Use localhost:8080 into the table django_site
Reference SO Thread: django-microsoft-auth : The provided value for the input parameter 'redirect_uri' is not valid
As you think, the first https is superfluous, you just need to delete it.
https://login.microsoftonline.com/50ce...90ac7/oauth2/v2.0/authorize?response_type=code&client_id=f4...27&redirect_uri=https://example.org/microsoft/auth-callback/&s...
By the way, I think there is no problem with the redirect_uri you set in the Azure portal.
I guess it is a problem of the redirecting URL. The example URL is coming from django site table. So first of all you need to enable the site:
#in settings.py
SITE_ID = 1
Afterwards you can go to the admin interface and set the url of the site to the correct domain. From my experience I know that it won't work without that.
My portfolio site has been deployed using Google App Engine, and it mostly works correctly, but one of my pages on the website doesn't work like it works when I just type python main.py on my machine. The page features one of my projects that takes as input an Excel file and does some processing using Openpyxl in Python, and gives the file back to download in the new layout. The problem is when I deployed the app I cannot seem to upload the Excel file, because I get an error "Error 3: Please choose a file to process" which is an error I just made in HTML when someone didn't choose an Excel file, but this error happens even if I chose an Excel File. I made like a "Download Sample Input" which is a typical file you can use in the program, then you choose a method and in this case "Rentmeester" and then click process. Then it takes like a second then it is finished processing and then you can download the new file. The problem is none of the processing works and the project basically is broken when I deployed it on App Engine and I don't know why or how to fix it. I struggle to get appropriate error logs in App Engine as I'm new to it. Here is the link of the broken project: https://christo.appspot.com/automate.html and here is a video of how it is supposed to work: https://youtu.be/nmDz4SmaKXY also here is all the source code for my entire Portfolio site on Github: https://github.com/CGVanWyk/Portfolio-Website I would really appreciate any light into this problem I am experiencing.
I think it may be because not all of my libraries are working or isn't imported correctly, but I'm not certain where to see if all the libraries is imported right or pip install'd. I tried this tutorial online with no success: https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27
https://github.com/CGVanWyk/Portfolio-Website
The code in question that isn't working is under /Templates/automate.html + failure.html + successful.html + inputFile.html + inputMethod.html for the HTML, /static/css/automate.css for the CSS, and most importantly main.py and helpers.py for the Python and Flask code and app.yaml just specifies the Python version. I don't know if I needed to include anything else there. I just followed this tutorial to deploy to Google App Engine https://cloud.google.com/appengine/docs/standard/python3/quickstart
Expected: successful.html when a file is inputted and the method was "Rentmeester" and the process button was clicked. Also there must be a new Excel file a user can download named "BEWERKTEFILE_RENT_SEPTEMBER2018.xlsx"
Actual: inputFile.html
I think that, maybe the problem could be that you're using App Engine Standard, and this way you can't write to disk as explained in this documentation[1], also I think the best practice is to use Cloud Storage to manage your App Engine files.
if this answer is helpful let me know.
[ 1 ] https://cloud.google.com/appengine/docs/the-appengine-environments
I'm new to this so I apologize in advance. I am actually an AppleScript developer and would merely like to use Uber Rides.py into a script, and I have virtually no knowledge in Python. (Just looking for an 'easy' way to initiate a Uber ride within a more complex script using Homebridge and Siri).
I've built the py app but I don't know to get the Oauth code after using the authorization_code_grant.py script.
I will be the only user of this app (it's just for testing at home) so I'm not that worried about Auth but I understand it's a mandatory uber process. There's no frontend to the app (it's just the script running and responding to Siri requests via Homebridge) and no web page for the user to authenticate. The user will be myself so I just need a way to "get" the Oauth code that I then will use as part of the CLI/Python command within the Applescript.
I have two main issues:
Can someone give me a step by step on how to grab the code sent by Uber once the user has logged in and clicked on the authorized button? I seem to understand I should configure my Apache server to "receive" the code but I don't know how to? (If it helps I have set up an Horuku account but I'm not sure I need this considering Apache runs on my Mac, I just don't know how to configure it…)
When I try to use the authorization_code py (with the URI set to http://localhost:7000 but, to my knowledge, nothing runs on port 7000 at the moment, hence question 1) it generates the error below
Error:
>mediacenter$ python example/authorization_code_grant.py
Login and grant access by going to:
login.uber.com/oauth/authorize?scope=profile+request+history&state=MgnYJ18l7DxqbSYxkSfjrbGCL8BQAMg0&redirect_uri=https%3A%2F%2Foauthswift.herokuapp.com%2Fcallback%2Fsiriuber&response_type=code&client_id=3Wk7zJbSLVCFCQ69UZvQJCZ_aBfHJBDu
>Copy the URL you are redirected to and paste here:
oauth-callback/siriuber?state=MgnYJ18l7DxqbSYxkSfjrbGCL8BQAMg0&code=dK1ETADCaHcZCAbXnYKOSapetgexgj
Failed to request access token: UNAUTHORIZED.
[ErrorDetails: 401 UNAUTHORIZED invalid_client]
Traceback (most recent call last):
File "example/authorization_code_grant.py", line 150, in
hello_user(api_client)
File "example/authorization_code_grant.py", line 122, in hello_user
response = api_client.get_user_profile()
AttributeError: 'NoneType' object has no attribute 'get_user_profile'
I hope it kind of makes sense. I know I should spend some time getting to learn a "real" language but AS is (most of the time) perfect to bring different things together quickly and doing what I want!
Thanks in advance,
JC
Same person from GitHub. After digging around, I came up with this.
Basically there is probably a configuration issue in either your example/config.yaml or in your app dashboard. Make sure you configured both of those correctly. the example/config.yaml setup should be exactly like this with the three values replaced. Make sure your redirect URL is the same as the one in your dashboard under "Authorizations" redirect URLs.
Did you install from source? As in did you clone it from the GitHub repo? Or did you install it using pip?
Hope this helps.
If there is someone out there who has already worked with SOLR and a python library to index/query solr, would you be able to try and answer the following question.
I am using the mySolr python library but there are others out (like pysolr) there and I don't think the problem is related to the library itself.
I have a default multicore SOLR setup, so no authentication required normally. Don't need it to access the admin page at http://localhost:8080/solr/testcore/admin/ either
from mysolr import Solr
solr = Solr('http://localhost:8080/solr/testcore/')
response = solr.search(q='*:*')
print("response")
print(response)
This code used to work but now I get a 401 reply from SOLR ... just like that, no changes have been made to the python virtual env containing mysolr or the SOLR setup. Still...something must have changed somewhere but I'm out of clues.
What could be the causes of a SOLR 401 reponse?
Additional info: This script and mor advanced script do work on another PC, just not on the one I am working on. Also, adding "/select?q=:" behind the url in the browser does return the correct results. So the SOLR is setup correctly, it has probably something to do with my computer itself. Could windows settings (of any kind) have an impact on how SOLR responds to requests from python? The python env itself has been reinstalled several times to no avail.
Thanks in advance!
The problem was: proxy.
If this exact situation was ever to occur to someone and you are behind a proxy, check if your HTTP and HTTPS environmental variables are not set. If they are... this might cause the python session to try using the proxy while it shouldn't (connecting to localhost via proxy).
It didn't cause any trouble for months but out of the blue it did so whether you encounter this or not might be dependent on how your IT setup your proxy or made some other changes...somewhere.
thank you everyone!