Snowflake Python connection using externalbrowser authenticator - python

I have code to connect to Snowflake through Python using external browser authentication (authenticator parameter set to 'externalbrowser')
I also have installed snowflake-connector-python version 2.3.5
On my machine running snowflake.connector.connect displays the following message, but doesn't open any browser windows to do the authentication:
"Initiating login request with your identity provider. A browser window should have opened for you to complete the login. If you can't see it, check existing browser windows, or your OS settings. Press CTRL+C to abort and try again..."
On my old machine it displays the same message, but opens a browser window to log in. What do you think can be causing this problem, and what can I do to fix this? Am I missing a package?

You want to try the troubleshooting suggested by Snowflake blog here EXTERNAL BROWSER SSO FROM CONNECTOR FAILS ON REDIRECT BACK TO LOCALHOST

I ran into the same issue, and do not set parameter "authenticator" to 'externalbrowser', if its optional you can remove this parameter and test.
after i remove "authenticator" parameter from my config file, I was able to authneticate and establish connection to snowflake.

You can try by allowing the pop up in your browser in the system settings

Related

Having trouble with Tryton/GNU Health installation

I have installed Tryton server and client as instructed on the GNU Health website. The server is running fine. The pre-requisites required - Postgresql, Python had been installed before hand. I have created a GNU Health user but whenever I attempt creating a database in postgres, i get the error shown in the terminal below -
This is my pg_hba.conf file, with the configuration as specified in the installation instruction -
Also, this is my trytond.conf file -
Please, can someone point out what i'm doing wrong because each time i run the Tryton client, it doesn't see any server and I an only run the demo profile. Also if I try creating a database from the Tryton client, It keeps giving me an error can't create database.
I have tried several edits to the conf file with no avail.
Any help in resolving this would be appreciated.
AFAIU you have to specify a username and password to let PostgreSQL trust your connection. Also take care that you are allowing anyone to conect to your server with any login. This may be a security issue.
Using the following URI works for me:
postgresql://username:sometext#localhost:5432

Google app engine endpoints api not working in localhost

I am trying to start a python app-engine project on localhost. I am in a Windows 8.1 machine (Python version 2.7). The project code is copied from here link. The server seems to start but the page wouldn't properly load due to some problem. Probably it can't reach the api server.
Here is a shot from firebug showing the failed request
What seems off to me is that in command prompt (I started the dev server from there) the API server is started at some random port other than the module port. But the webpage is trying to access the http://127.0.0.1:8000/_ah/api/static/proxy.html... page at the module port. I tried accessing it at the API server port it does open some page there. (I mean I tried opening http://127.0.0.1:1532/_ah/api/static/proxy.html... seperately) It returns some json I don't understand...
{app_id: dev~udatut-bs, rtok: '0'}
Command prompt log:
Here's the difference between the outputs in localhost and *.appspot.com
Should get this:
But stuck here:(check buttons are not loaded)
I finally found a solution here.
Steps for windows:
Goto your google appengine installation folder and then ./google/appengine/toots. (C:\Program Files (x86)\Google\google_appengine\google\appengine\tools) if you followed default installation instructions.
Open the file appengine_rpc.py and look for the line (towards the end of the file)
opener.add_handler(fancy_urllib.FancyProxyHandler())
and comment it out like
# opener.add_handler(fancy_urllib.FancyProxyHandler())
Close the app and restart it again.

Flask app fails to render when deploying code to Azure Web with a database connection, but works fine from local server

I have an Azure web app with a Flask template. I want it to connect to a SQL database. I made one. I installed pymssql. For testing purposes I added to the views.py in the root folder:
import pymssql
conn = pymssql.connect(server='mydb.database.windows.net', user='mydbnameadmin#mydb', password='secret', database='mydb')
I first tested locally on my kubuntu box. To make sure I was getting a connection, I entered the wrong password, and the server threw an error. I entered it correctly and the error disappeared. Cool. Also the SQL dashboard on the azure portal reported sucessfull connections. So then I pushed my changes (including updating the requirements.txt) to my github repo and it was sucked into my web application. When I tried running the web app, on the index page:
The page cannot be displayed because an internal server error has
occurred.
After turning on and inspecting the detailed logs all I get it:
HTTP Error 500.0 - Internal Server Error
The page cannot be displayed because an internal server error has occurred.
Most likely causes:
IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
IIS was not able to process configuration for the Web site or application.
The authenticated user does not have permission to use this DLL.
The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
IIS. What's that doing here? I thought MS was trendy and hosted this service on a linux box 0_0
I remove the second line
conn = pymssql.connect(server='mydb.database.windows.net', user='mydbnameadmin#mydb', password='secret', database='mydb')
and the error disappeared. If I run a server locally, which still uses the Azure SQL server, I don't have any issues.
This seems to be the same issue I have:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/e20bb2a3-bdbe-4e49-8b92-b36fe50577da/having-trouble-deploying-flask-app-into-azure-with-azure-database?forum=windowsazurewebsitespreview&prof=required
but they say whether they actually got it working with a SQL database...
what do people think?
Thanks
my requirements.txt
alembic==0.7.7
azure==0.11.1
Flask==0.10.1
Flask-Migrate==1.5.0
Flask-Script==2.0.5
Flask-SQLAlchemy==2.0
futures==3.0.3
itsdangerous==0.24
Jinja2==2.8
Mako==1.0.1
MarkupSafe==0.23
pymssql==2.1.1
python-dateutil==2.4.2
six==1.9.0
SQLAlchemy==1.0.8
Werkzeug==0.10.4
wheel==0.24.0
Per my understanding, Azure Web sites are hosted on Windows Server 2012 VM by default, which would not install FreeTDS and also we don't have permission to install it. And the pymssql is based on FreeTDS.
So we can use pyodbc to connect the Azure SQL as a workaround way to handle it in ease.
I was able to successfully connect my Python code to a SQL Database on Azure using the pymssql 2.1 library.
I don't know if this is what is causing the problem but I did include a couple of extra parameters in my connection string... maybe that will help. I specified the driver explicitly and the Encrypt parameter since SSL is always enabled for SQL Azure (I believe)
myConnection = pyodbc.connect('Driver={SQL Server};'
'Server=tcp:1234567.database.windows.net,1433;'
'Database=MyAzureDatabase;'
'Uid=geekgirl#123456;Pwd=abcdef;'
'Encrypt=yes')
If that doesn't work, maybe try adding some error handling around the connect statement to try and get a more specific error message.
Fingers crossed!
I had this problem, but I eventually realized it was because I was using the 64-bit version of Python in Visual Studio, but Azure only supports the 32-bit version.
I was seeing:
DLL load failed: %1 is not a valid Win32 application.
Once I switched to installing and using the 32-bit version I was able to use Flask and pyodbc with no problems.

Google Analytics API access without local browser in python

I want to query the Google Analytics API using Python to periodically download data from my Analytics account and store data in a local database. I am basically following the steps as given in the basic tutorial. I am using the Google client API library for Python in this process.
My script is working fine so far when I am running it on my local dev machine (Mac). When I start the script, my browser opens and I am prompted to grant access to my Analytics data from the app. Afterwards I can run my script as often as I want and get access to my data.
On my server (Ubuntu, only terminal available), the w3m browser opens, but I cannot access my Google account from there. I can only quit w3m and kill the program with Ctrl-C. There is an error message like:
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?scope=some_long_url&access_type=offline
If your browser is on a different machine then exit and re-run this
application with the command-line parameter
--noauth_local_webserver
However when I run my script with the parameter --noauth_local_webserver, I get the same results - w3m opens and I cannot authenticate.
How can I get the --noauth_local_webserver to work? I there another way to authenticate without a local browser on the same machine?
When you use FLAGS = gflags.FLAGS, you actually need to pass the command-line arguments to FLAGS (this may or may not have tripped me up as well :) ). See here for an Analytics-centric example of how to do it (code below as links tend to go away after a while). General idea is that argv arguments are passed into the FLAGS variable, which then become available to other modules.
# From samples/analytics/sample_utils.py in the google-api-python-client source
def process_flags(argv):
"""Uses the command-line flags to set the logging level.
Args:
argv: List of command line arguments passed to the python script.
"""
# Let the gflags module process the command-line arguments.
try:
argv = FLAGS(argv)
except gflags.FlagsError, e:
print '%s\nUsage: %s ARGS\n%s' % (e, argv[0], FLAGS)
sys.exit(1)
# Set the logging according to the command-line flag.
logging.getLogger().setLevel(getattr(logging, FLAGS.logging_level))
Also, turns out that we aren't alone! You can track this bug to see when this will get added the documentation.
you can also use GA as a service API:https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-py
this works perfectly fine. Just remmeber to convert the p12 to an unencryptet PEM file using openssl
$openssl pkcs12 -in client_secrets.p12 -nodes -nocerts > client_secrets.pem
the import password is printed out when you download the P12 from google developer's console
I ran into the same issue and managed to solve it by SSHing into my server. Example:
ssh -L 8080:127.0.0.1:8080 <server-name>
I then ran my script through SSH. When I was presented with the URL (https://accounts.google.com/o/oauth2/auth?scope=some_long_url&access_type=offline), I copied and pasted into the browser on my machine to complete the authentication flow.
I ran it on my PC, got a token.json, and just copied the token on the server in the home folder (think working directory of the script), it solved it.
No authentication needed if you use same token

Installing Chrome Native Client SDK

For the last few days I have been trying ti install the Native Client SDK for chrome in Windows and/or Ubuntu.
I'm behind a corporate network, and the only internet access is through an HTTP proxy with authentication involved.
When I run "naclsdk update" in Ubuntu, it shows
"urlopen error Tunnel connection failed: 407 Proxy Authentication Required"
Can anyone please help ?
Try to download this file:
http://commondatastorage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/naclsdk_manifest2.json
It is the native client update summary, but in the URL I replaced the https with http. If you view the JSON file, you will see the different pepper_xx versions available. Use the links to download the one you want, but again replace https with http.
The naclsdk update tool is very difficult to use for those of us behind a strict firewall. It would be nice if Google provided a direct link to the latest SDK.
I got a solution-
not a direct one, though.
managed to use a program to redirect the HTTPS traffic through the HTTP proxy.
I used the program called "proxifier". Works great.

Categories

Resources