Why I can't configure OAuth 2.0 using Python? - python

I was trying to get my uploading YouTube video software to work using this guide/code:
https://developers.google.com/youtube/v3/guides/uploading_a_video
I installed & setup everything that is requiered. Also, I made new project, changed YouTube Data API v3's state to ON, got my credentials, entered them to client_secrets.json (also tried downloading one via button that google provided, btw. I renamed downloaded one to client_secrets.json manually, so that's not problem) but when I try to upload something I get this error:
C:\Users\%USERNAME%>c:/Python27/python.exe C:\Users\%USERNAME%\Documents\youtube_uploader\up
load.py --file=C:\Users\%USERNAME%\Documents\youtube_uploader\test_klip\test.mp4 --tit
le=Test upload
WARNING: Please configure OAuth 2.0
To make this sample run you will need to populate the client_secrets.json file
found at:
C:\Users\%USERNAME%\Documents\youtube_uploader\clientinfo.json
with information from the APIs Console
https://code.google.com/apis/console#access
For more information about the client_secrets.json file format, please visit:
https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
Is there anything I missed or done wrong? If so, please help me to get this to work.
Thanks in advance! :)
P.S. I tried making and using both web/installed type of credentials but none of them work.

Related

Sharepoint API how to read file havin only sharing link to it

I'm using python office365 library to access sharepoint documents. I don't know how to access file via API that have been shared with me by sharing link. I need to get this file content and if possible metadata (last modify date). Could anyone help?
The user that I'm using have no access to this sharepoint folder other than a sharing link to a single file.
I tried many variations of normal file access API, bot by hand and by office365 library. I couldnt find a way to access a file when I have only sharing link to it.
My sharing link looks like that:
https://[redacted].sharepoint.com/:x:/s/[redacted]/dir1/dir2/ESd0HkNNSbJMhQFavQsr9-4BNHC2rHSWsnbs3zRdjtZsC3g so there is not really a filename here and I cannot read via API content of any folder per se because I have an error Attempted to perform an unathorized operation.. Authentication goes fine (when i mistake password I get different error).
According to my research and testing, you can use the following Rest API to read file (get file content):
https://xxxx.sharepoint.com/sites/xxx/_api/web/GetFolderByServerRelativeUrl('/sites/xxx/Library_Name/Folder Name')/Files('Document.docx')/$value
If you want to get last modify date, you can use the following Rest API to get the Modified field:
https://xxxx.sharepoint.com/sites/xxx/_api/web/lists/getbytitle('test_library')/Items?$select=Modified

Pyrebase uploaded image not loading firebase storage

I'm not able to make this work, I want to upload a picture to firebase with pyrebase and the file(picture) goes through but it never loads on firebase/storage (see picture attached)
This is the code:
if request.method == 'POST':
upload = request.files['upload']
upload.save(os.path.join(UPLOAD_FOLDER, filename))
storage.child("images/test.jpg").put(UPLOAD_FOLDER+filename)
Last I heard, there is a bug in the Firebase console where images don't load if they were uploaded using one of the backend SDKs (as opposed to one of the Firebase client SDKs, or the Firebase console). It uses the "access token" that you would see in the "File location" section for that file. If there is no access token, the console won't know how to load the file.
If this is indeed the case for you, please file a bug with Firebase support. It's a known issue, but the report will let them know how many people are affected.
Clicking Create new access token under File Location solves the issue.

Exception 400081 while downloading a view using TableauServerClient

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.

Google cloud translate API - "Daily Limit Exceeded"

I'm writing a bit of python using the google cloud api to translate some text.
I have set up billing on my account and it says it's active (with some credit added for the free trial). I created an application_default_credentials.json file with -
gcloud auth application-default login
Which asked me to log in to my account (I logged into the same account I set billing up on).
I then used -
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "/home/theo/.config/gcloud/application_default_credentials.json"
at the start of my python script. For the coding I followed these samples here - https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/translate/cloud-client
Yesterday the api wouldn't work and I would receive "daily limit exceeded" even though I had not used it yet. Eventually I gave up and decided to sleep on it.
Tried again today and it was working. Without having to do anything. Ah great I thought, it must just have taken a while to update my billing information.
But I've since translated a few things, maybe 10000 characters and I'm already receiving the same error message.
I did create a "Project" on the cloud console and have an api key from there. I'm not entirely sure how to use it because the documentation I linked above just uses the json credentials file. From what I've read online, using the json file is recommended over using a key now.
Any ideas about what I need to do?
Thanks.
Solved by creating a token at https://console.cloud.google.com/apis/credentials/serviceaccountkey instead of the one created with the gcloud auth command.
After I referenced the generated json file from that page it started working.
More info here - https://cloud.google.com/docs/authentication/getting-started

Google Adwords API - refresh token - python

I am in the process of setting up with Google Adwords API. They have a fantastic guide (https://developers.google.com/adwords/api/docs/guides/start), with the exception that one of the last steps is rather vague.
I have gotten to this step, pictured here (but from the link above)
I am instructed (for Python) to put the client ID and client secret into my own configuration file. All the other languages have specific files that were added to need to be edited (such as the PHP example below).
I have been working at this for the past 3 hours, and tried googling and youtubing and reading through every piece of documentation I can find. All of them just say "add the ID and secret to your config file." I have no idea what that means, or how to do it. I've gone into my python directory and found a file named "config.py", but have no idea how to add these credentials. There is a number of scripts on github (that Google links to), one of them for generating a refresh token, like I want. I have no idea how to implement this, though.
https://github.com/googleads/googleads-python-lib/tree/master/examples/adwords/authentication
Thank you in advance for any insight into adding credentials to my python config file or otherwise generating a refresh token.
I found the answer.
In short, the config file is in a directory that was not included in the instructions. It is advisable to download the entire "googleads-python-lib" directory versus just the directory "googlead".
https://github.com/googleads/googleads-python-lib
The config file (googleads.yaml) is within this "googleads-python-lib" directory. I unzipped it in my python2.7/site-packages. There are variables in this config file ready to take your authentication credentials.

Categories

Resources