jwass / geojsonio.py

Open GeoJSON data on geojson.io
BSD 2-Clause "Simplified" License
121 stars 25 forks source link

Fixed auth #12

Open medeirosjoaquim opened 6 years ago

medeirosjoaquim commented 6 years ago

Created auth(gituser, gitpass) and testauth() methods.

To solve the issue (https://github.com/jwass/geojsonio.py/issues/11) I had to create an auth method using github3.py.

jwass commented 6 years ago

Hi @medeirosjoaquim, Thanks for contributing this!

Any chance you can get the tests running so this can be merged?

Sti2nd commented 5 years ago

Please fix this!

medeirosjoaquim commented 5 years ago

Please fix this!

Done!

medeirosjoaquim commented 5 years ago

Hi @medeirosjoaquim, Thanks for contributing this!

Any chance you can get the tests running so this can be merged?

It's done.

Sti2nd commented 5 years ago

Wow! Great! Thank you @medeirosjoaquim ❤️

hyperknot commented 5 years ago

How do you install this non-released fix? I'm trying everything like

pip install git+https:///github.com/jwass/geojsonio.py.git@master

But it still results in exception:

File "venv/lib/python3.7/site-packages/geojsonio/geojsonio.py", line 36, in display
    url = make_url(contents, domain, force_gist)
  File "venv/lib/python3.7/site-packages/geojsonio/geojsonio.py", line 93, in make_url
    gist = _make_gist(contents)
  File "venv/lib/python3.7/site-packages/geojsonio/geojsonio.py", line 172, in _make_gist
    gist = ghapi.create_gist(description, files)
  File "venv/lib/python3.7/site-packages/github3/decorators.py", line 37, in auth_wrapper
    raise error_for(r)
github3.exceptions.AuthenticationFailed: 401 Requires authentication
medeirosjoaquim commented 5 years ago

How do you install this non-released fix? I'm trying everything like

pip install git+https:///github.com/jwass/geojsonio.py.git@master

But it still results in exception:

File "venv/lib/python3.7/site-packages/geojsonio/geojsonio.py", line 36, in display
    url = make_url(contents, domain, force_gist)
  File "venv/lib/python3.7/site-packages/geojsonio/geojsonio.py", line 93, in make_url
    gist = _make_gist(contents)
  File "venv/lib/python3.7/site-packages/geojsonio/geojsonio.py", line 172, in _make_gist
    gist = ghapi.create_gist(description, files)
  File "venv/lib/python3.7/site-packages/github3/decorators.py", line 37, in auth_wrapper
    raise error_for(r)
github3.exceptions.AuthenticationFailed: 401 Requires authentication

while it's not merged , you can try it from the fork I've made to implement the fix, here https://github.com/medeirosjoaquim/PyGeoJson

although I've made it kinda in a hurry to pass the tests in the repo. Try it and tell my if it works alright. If not, send me the errors.

xindi-dumbledore commented 5 years ago

I have AttributeError: module 'geojsonio' has no attribute 'auth' when doing

myAuth = geojsonio.auth('username','password')

Also, the documentation on the fork is kind of misleading since it still suggest doing pip install geojsonio... Additionally I got super confused because seems from the original source code, I should put a gitauth.txt?

medeirosjoaquim commented 5 years ago

I have AttributeError: module 'geojsonio' has no attribute 'auth' when doing

myAuth = geojsonio.auth('username','password')

Also, the documentation on the fork is kind of misleading since it still suggest doing pip install geojsonio... Additionally I got super confused because seems from the original source code, I should put a gitauth.txt?

It's not documentation of the fork. In fact, it's not a fork. I forked for those who wanted to try the fix because it's a PR and it's waiting for the maintainer to merge. I did the fix almos a year ago and only a few months ago I finished the tests. If in some weekend to come I have the time, I will try to put it in order and then I reply here. Thanks for your comment!

medeirosjoaquim commented 5 years ago

I have AttributeError: module 'geojsonio' has no attribute 'auth' when doing

myAuth = geojsonio.auth('username','password')

Also, the documentation on the fork is kind of misleading since it still suggest doing pip install geojsonio... Additionally I got super confused because seems from the original source code, I should put a gitauth.txt?

I just made a little clean up in the read-me file, and tested again the fix. Works ok.

You will not install it. You must have the gitauth.txt in the same folder as the geojsonio.py and then just run the script (python geojsonio.py yourdataset.geojson)... Hope it helps. you can check my test here : https://gist.github.com/medeirosjoaquim/ba7df592d29f1e358f3f249bb1cbbce4

SuryaSankar commented 5 years ago

Can this be merged please? This issue is blocking the adoption of this library

medeirosjoaquim commented 5 years ago

Can this be merged please? This issue is blocking the adoption of this library

in the meanwhile, you can use the fork with the fix. You don't need to pip install, just get the files, put your credentials and run.

https://github.com/medeirosjoaquim/PyGeoJson

BizYoder commented 4 years ago

Hi @medeirosjoaquim, I can't get your solution to work. I keep getting the following:

Bizs-MacBook-Pro:PyGeoJson-master bizyoder$ python geojsonio.py africagrid20170906existing.geojson Traceback (most recent call last): File "geojsonio.py", line 236, in main() File "geojsonio.py", line 229, in main url = make_url(contents, args.domain) File "geojsonio.py", line 106, in make_url gist = _make_gist(contents) File "geojsonio.py", line 186, in _make_gist gist = gh.create_gist(description, files) File "/Users/bizyoder/anaconda3/lib/python3.6/site-packages/github3/github.py", line 149, in create_gist json = self._json(self._post(url, data=new_gist), 201) File "/Users/bizyoder/anaconda3/lib/python3.6/site-packages/github3/models.py", line 90, in _json if self._boolean(response, status_code, 404) and response.content: File "/Users/bizyoder/anaconda3/lib/python3.6/site-packages/github3/models.py", line 108, in _boolean raise GitHubError(response) github3.models.GitHubError: 502 Server Error

Any thoughts?

medeirosjoaquim commented 4 years ago

github3.models.GitHubError: 502 Server Error

Hi! How are you? I will take a look. But, since it's a 502 error, it looks like a Github's downtime. I would be nice if the fix were merged to work on this.

medeirosjoaquim commented 4 years ago

Hi @medeirosjoaquim, I can't get your solution to work. I keep getting the following:

Bizs-MacBook-Pro:PyGeoJson-master bizyoder$ python geojsonio.py africagrid20170906existing.geojson Traceback (most recent call last): File "geojsonio.py", line 236, in main() File "geojsonio.py", line 229, in main url = make_url(contents, args.domain) File "geojsonio.py", line 106, in make_url gist = _make_gist(contents) File "geojsonio.py", line 186, in _make_gist gist = gh.create_gist(description, files) File "/Users/bizyoder/anaconda3/lib/python3.6/site-packages/github3/github.py", line 149, in create_gist json = self._json(self._post(url, data=new_gist), 201) File "/Users/bizyoder/anaconda3/lib/python3.6/site-packages/github3/models.py", line 90, in _json if self._boolean(response, status_code, 404) and response.content: File "/Users/bizyoder/anaconda3/lib/python3.6/site-packages/github3/models.py", line 108, in _boolean raise GitHubError(response) github3.models.GitHubError: 502 Server Error

Any thoughts?

Hi! I took a look,. it still works fine here. I've noticed that you're using python3. This repo was set first with python 2.7 . Would you mind trying to run it with python 2.7 and then tell me if it works? Perhaps in the python 3 lib for github api the URLs are different and, because of that, it's receiving this 502 error.

medeirosjoaquim commented 4 years ago

UPDATE:

Now you should use an ACCESS TOKEN. It's cleaner and safer. just go to my fork and follow the instructions:

https://github.com/medeirosjoaquim/PyGeoJson

ShrimpandGits commented 2 years ago

a suggestion, I don't know if Git updated Auth tokens, but I ran into some trouble last night:

The new path is:

Settings > Developer settings > Personal access tokens

Select scopes:

gist - Create gists (checked)

ShAssaf commented 1 year ago

Hi, still having this issue