Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 - Forbidden #87

Closed
Zhanchenhaha opened this issue Sep 3, 2018 · 34 comments
Closed

403 - Forbidden #87

Zhanchenhaha opened this issue Sep 3, 2018 · 34 comments

Comments

@Zhanchenhaha
Copy link

kaggle competitions download favorita-grocery-sales-forecasting -f test.csv.7z
403 - Forbidden

@ghost
Copy link

ghost commented Sep 3, 2018

Need way more information. What version of the API are you running? Have you accepted the competition's rules? Are you able to download files using the web ui?

@k-hashimoto
Copy link

k-hashimoto commented Sep 3, 2018

I have same issue. These commands worked well.

kaggle competitions list
kaggle competitions files titanic

But kaggle competitions download -c titanic and kaggle competitions download -c titanic -f train.csv didn't work. This command return 403 - Forbidden

My env. is
Kaggle API 1.4.7.1
Python 3.5.0

@k-hashimoto
Copy link

k-hashimoto commented Sep 3, 2018

This was my mistake. Incoming users need to accept rules. After accepting rules we can download dataset by using kaggle command.

https://www.kaggle.com/c/titanic/rules

But in this case, kaggle command just return "403 - Forbidden". I think this is unkind for new users. You should improve and client should show useful information for us(ex. url).

@Zhanchenhaha
Copy link
Author

thank you

@MoZeWei
Copy link

MoZeWei commented Sep 4, 2018

@k-hashimoto But why did I click the accept botton in that webpage and go back to use kaggle command to download it, which still got a 403 -forbidden error?

@ghost
Copy link

ghost commented Sep 4, 2018

@LoveJTimberlake Are you also using the latest version of the API? Are you able to download files through the website?

@MoZeWei
Copy link

MoZeWei commented Sep 8, 2018

@rysteboe Yes API's version is 1.4.7.1 and Python3.6
I am in China and I can download data through website. I clicked Accept Botton and then the website jumped to another which needed me to verify phone number. I ignored it and used download command to download it, it still led to 403 -forbidden error. Why?

@ghost
Copy link

ghost commented Sep 10, 2018

@LoveJTimberlake you have to have a verified phone number in order to download competition data. If that doesn't work, please reach out here - https://www.kaggle.com/contact, because this doesn't sound like an API specific problem.

@ghost ghost closed this as completed Sep 10, 2018
@Fasih1994
Copy link

Fasih1994 commented Mar 19, 2019

i verified my phone number and also verified the code given by kaggle to my phone but still getting 403 error
on : kaggle competitions download -c dogs-vs-cats

@bingo0123
Copy link

i am also unable to download dataset even after verifying my phone number .i am using python3 and kaggle new API.i am using following command in collab.
!kaggle competitions download -c LANL-Earthquake-Prediction

@tobias-khs
Copy link

If you still get 403 Forbidden I had to click the Late Submission-button (and then accept). Solved it thanks to maryb on fastai-forum

@xanjay
Copy link

xanjay commented May 21, 2019

You need to click join competition and accept the rules. Even if that't not working you can try expire api token and create new api token @bingo0123

@apoorvtomar2222
Copy link

Correct. you must have done with all the prerequisite of kaggle like you must have your number verified and other basic verification along with it you must have joined the competetion.

This a consolidated answer which worked for me as whole.

@AnaDataScience
Copy link

@bingo0123 Click on the "Late Submission" button on the Kaggle page of the competition whose data you want to download, and retry the same command.
Works.

@priyanshgupta1998
Copy link

priyanshgupta1998 commented Jun 3, 2019

I'm working on google colab and I've been through the same problem. but i did two tings .

First you have to register your mobile number along with your country code.
Second you have to click on last submission on the kaggle dataset page
Then download kaggle.json file from kaggle.
After that on google colab
!pip install -q kaggle
!mkdir -p ~/.kaggle
!cp kaggle.json ~/.kaggle/
!chmod 600 ~/.kaggle/kaggle.json
!kaggle competitions download -c web-traffic-time-series-forecasting

@rake5h1
Copy link

rake5h1 commented Apr 8, 2020

You need to accept the rules first

@stoufa
Copy link

stoufa commented Apr 27, 2020

Can we replace that ambiguous 403 - Forbidden message with a better one ?
Something like You didn't accept the competition rules, accept now ? [Y/n]

@venkateshchittinidi
Copy link

You need to click join competition and accept the rules. Even if that't not working you can try expire api token and create new api token @bingo0123

Exactly correct !!!
I got the same error and solved

@ghost
Copy link

ghost commented May 17, 2021

I am getting 401 error after accepting the rules and getting into the competition I am able to download it as a zip but not through api.

@natke
Copy link

natke commented Dec 3, 2021

Wow, yes this needs way more information for the user. The only way I knew about this was finding this GitHub issue

@nocibambi
Copy link

And still...

@sheecegardezi
Copy link

Can we replace that ambiguous 403 - Forbidden message with a better one ? Something like You didn't accept the competition's rules, accept now ? [Y/n]

this will be a good solution

@adutta93
Copy link

If verifying the phone number is not working, click the 'Late Submission" button, it'll work.

@sheecegardezi
Copy link

Why is this issue closed?

@massisenergy
Copy link

Facing the same issue, while trying the notebook from the fast.ai course, to run on my local computer!

import os
iskaggle = os.environ.get('KAGGLE_KERNEL_RUN_TYPE', '')

path = Path('us-patent-phrase-to-phrase-matching')
if not iskaggle and not path.exists():
    import zipfile,kaggle
    kaggle.api.competition_download_cli(str(path))
    zipfile.ZipFile(f'{path}.zip').extractall(path)

ApiException Traceback (most recent call last)
Cell In [28], line 3
1 if not iskaggle and not path.exists():
2 import zipfile,kaggle
----> 3 kaggle.api.competition_download_cli(str(path))
4 zipfile.ZipFile(f'{path}.zip').extractall(path)

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:757, in KaggleApi.competition_download_cli(self, competition, competition_opt, file_name, path, force, quiet)
755 else:
756 if file_name is None:
--> 757 self.competition_download_files(competition, path, force,
758 quiet)
759 else:
760 self.competition_download_file(competition, file_name, path,
761 force, quiet)

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/api/kaggle_api_extended.py:718, in KaggleApi.competition_download_files(self, competition, path, force, quiet)
714 else:
715 effective_path = path
717 response = self.process_response(
--> 718 self.competitions_data_download_files_with_http_info(
719 id=competition, _preload_content=False))
720 url = response.retries.history[0].redirect_location.split('?')[0]
721 outfile = os.path.join(effective_path,
722 competition + '.' + url.split('.')[-1])

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/api/kaggle_api.py:400, in KaggleApi.competitions_data_download_files_with_http_info(self, id, **kwargs)
397 # Authentication setting
398 auth_settings = ['basicAuth'] # noqa: E501
--> 400 return self.api_client.call_api(
401 '/competitions/data/download-all/{id}', 'GET',
402 path_params,
403 query_params,
404 header_params,
405 body=body_params,
406 post_params=form_params,
407 files=local_var_files,
408 response_type='Result', # noqa: E501
409 auth_settings=auth_settings,
410 async_req=params.get('async_req'),
411 _return_http_data_only=params.get('_return_http_data_only'),
412 _preload_content=params.get('_preload_content', True),
413 _request_timeout=params.get('_request_timeout'),
414 collection_formats=collection_formats)

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/api_client.py:329, in ApiClient.call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _request_timeout)
292 """Makes the HTTP request (synchronous) and returns deserialized data.
293
294 To make an async request, set the async_req parameter.
(...)
326 then the method will return the response directly.
327 """
328 if not async_req:
--> 329 return self.__call_api(resource_path, method,
330 path_params, query_params, header_params,
331 body, post_params, files,
332 response_type, auth_settings,
333 _return_http_data_only, collection_formats,
334 _preload_content, _request_timeout)
335 else:
336 thread = self.pool.apply_async(self.__call_api, (resource_path,
337 method, path_params, query_params,
338 header_params, body,
(...)
342 collection_formats,
343 _preload_content, _request_timeout))

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/api_client.py:161, in ApiClient.__call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout)
158 url = self.configuration.host + resource_path
160 # perform request and return response
--> 161 response_data = self.request(
162 method, url, query_params=query_params, headers=header_params,
163 post_params=post_params, body=body,
164 _preload_content=_preload_content,
165 _request_timeout=_request_timeout)
167 self.last_response = response_data
169 return_data = response_data

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/api_client.py:351, in ApiClient.request(self, method, url, query_params, headers, post_params, body, _preload_content, _request_timeout)
349 """Makes the HTTP request using RESTClient."""
350 if method == "GET":
--> 351 return self.rest_client.GET(url,
352 query_params=query_params,
353 _preload_content=_preload_content,
354 _request_timeout=_request_timeout,
355 headers=headers)
356 elif method == "HEAD":
357 return self.rest_client.HEAD(url,
358 query_params=query_params,
359 _preload_content=_preload_content,
360 _request_timeout=_request_timeout,
361 headers=headers)

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/rest.py:247, in RESTClientObject.GET(self, url, headers, query_params, _preload_content, _request_timeout)
245 def GET(self, url, headers=None, query_params=None, _preload_content=True,
246 _request_timeout=None):
--> 247 return self.request("GET", url,
248 headers=headers,
249 _preload_content=_preload_content,
250 _request_timeout=_request_timeout,
251 query_params=query_params)

File ~/.pyenv/versions/3.10.6/envs/venv_torch-gpu/lib/python3.10/site-packages/kaggle/rest.py:241, in RESTClientObject.request(self, method, url, query_params, headers, body, post_params, _preload_content, _request_timeout)
238 logger.debug("response body: %s", r.data)
240 if not 200 <= r.status <= 299:
--> 241 raise ApiException(http_resp=r)
243 return r

ApiException: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Sat, 19 Nov 2022 10:46:29 GMT', 'Access-Control-Allow-Credentials': 'true', 'Set-Cookie': 'ka_sessionid=f0c5afe55cbcccdb1a713cee0482265a; max-age=2626560; path=/, GCLB=CPf0svfYvZjFNQ; path=/; HttpOnly', 'Transfer-Encoding': 'chunked', 'Vary': 'Accept-Encoding', 'Turbolinks-Location': 'https://www.kaggle.com/api/v1/competitions/data/download-all/%2FUsers%2Fmassisenergy%2FLibrary%2FMobile%5C%20Documents%2Fcom~apple~CloudDocs%2FSync%2FCoding%2FPython%2Fvenv_torch-gpu%2FTransformers_HuggingFace%F0%9F%A4%97%2Fus-patent-phrase-to-phrase-matching', 'X-Kaggle-MillisecondsElapsed': '50', 'X-Kaggle-RequestId': '0dfe69de37a49d47751f4a9a868cc282', 'X-Kaggle-ApiVersion': '1.5.12', 'X-Frame-Options': 'SAMEORIGIN', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Content-Security-Policy': "object-src 'none'; script-src 'nonce-v9yOyUjm3o5RfhOvXnmJtA==' 'report-sample' 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:; frame-src 'self' https://www.kaggleusercontent.com/ https://www.youtube.com/embed/ https://polygraph-cool.github.io/ https://www.google.com/recaptcha/ https://form.jotform.com/ https://submit.jotform.us/ https://submit.jotformpro.com/ https://submit.jotform.com/ https://www.docdroid.com/ https://www.docdroid.net/ https://kaggle-static.storage.googleapis.com/ https://kaggle-static-staging.storage.googleapis.com/ https://kkb-dev.jupyter-proxy.kaggle.net/ https://kkb-staging.jupyter-proxy.kaggle.net/ https://kkb-production.jupyter-proxy.kaggle.net/ https://kkb-dev.firebaseapp.com/ https://kkb-staging.firebaseapp.com/ https://kkb-production.firebaseapp.com/ https://kaggle-metastore-test.firebaseapp.com/ https://kaggle-metastore.firebaseapp.com/ https://apis.google.com/ https://content-sheets.googleapis.com/ https://accounts.google.com/ https://storage.googleapis.com/ https://docs.google.com/ https://drive.google.com/ https://calendar.google.com/; base-uri 'none'; report-uri https://csp.withgoogle.com/csp/kaggle/20201130;", 'X-Content-Type-Options': 'nosniff', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'})
HTTP response body: b'{"code":403,"message":"Required permission \u0027competitions.get\u0027 was not satisfied"}'

@LinarKulinar
Copy link

I'll post my solution to the problem.
I got a "403 - Forbidden" error when trying to fetch a dataset using kaggle-api marked [Private Dataset].
Obviously, I simply did not have rights to this particular dataset.

@wallinb
Copy link

wallinb commented Mar 14, 2023

Yet another way this 403 error can happen is if you use the url for the competition (e.g. the first column in kaggle competitions list) rather than just the competition suffix:

Use: kaggle competitions download -c asl_signs
Not: kaggle competitions download -c https://www.kaggle.com/competitions/asl-signs

@Swaranshpatel
Copy link

kaggle datasets download -d frabbisw/facial-age its working for me

@imanehmz
Copy link

For the datasets, you can use !kaggle datasets download username/dataset_name , I had a mistake becauseI was using the link, if you're using competitions then you should use the link to the dataset.

@sarahlunette
Copy link

Hi ! I am experiencing the same issue - and the file is the kaggle folder and I use the username and I get this: 403 - Forbidden - Permission 'competitions.participate' was denied
And I have accepted the rules on the website and I have also applied for the competition

@imanehmz
Copy link

Hi ! I am experiencing the same issue - and the file is the kaggle folder and I use the username and I get this: 403 - Forbidden - Permission 'competitions.participate' was denied And I have accepted the rules on the website and I have also applied for the competition

What command did you use and for which competition?

@dineiar
Copy link

dineiar commented May 20, 2024

Hi ! I am experiencing the same issue - and the file is the kaggle folder and I use the username and I get this: 403 - Forbidden - Permission 'competitions.participate' was denied And I have accepted the rules on the website and I have also applied for the competition

What command did you use and for which competition?

Sorry for resurfacing this, but I am receiving this same error message when trying to join this competition to download its dataset: https://www.kaggle.com/c/twitter-bot-classification/data

I am facing this on the website, which I believe consumes the API.

@saikiran816
Copy link

Hi ! I am experiencing the same issue - and the file is the kaggle folder and I use the username and I get this: 403 - Forbidden - Permission 'competitions.participate' was denied And I have accepted the rules on the website and I have also applied for the competition

This is a issue you will get when the competition is "Invitation Only" but you don't have invitation.

@dineiar
Copy link

dineiar commented Jul 3, 2024

This is a issue you will get when the competition is "Invitation Only" but you don't have invitation.

Thanks for clarifying it. Is there a reliable way to identify if a given competition is Invitation Only? I did not find this information on Kaggle's website.

btw, I believe the API and the website should show a clearer error message for this case. "You are not invited to the competition" would be better than the current message.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests