Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Credential-based login is broken after removal of /session endpoint #380

Closed
Labels
@GhostLyrics

Description

@GhostLyrics

Remove Session API now that private tokens are removed from user API endpoints.

/api/v4/session has been removed and it is currently not possible to log in via email/password combination. [Deprecation notice,Changelog]

I use this to completely automate testing (e.g. create a GitLab instance, set a password for root, run some tests, tear everything down).

wget http://gitlab/api/v4/session--2017-11-23 23:06:57--  http://gitlab/api/v4/sessionResolving gitlab (gitlab)... 192.168.34.151, 192.168.34.151Connecting to gitlab (gitlab)|192.168.34.151|:80... connected.HTTP request sent, awaiting response... 404 Not Found2017-11-23 23:06:57 ERROR 404: Not Found.
importgitlabs=gitlab.Gitlab('http://localhost',email='root',password='some_test_password',api_version=4)s.auth()Traceback (mostrecentcalllast):File"<input>",line1,in<module>s.auth()File "/Users/ghostlyrics/.pyenv/versions/3.5.3/lib/python3.5/site-packages/gitlab/__init__.py",line197,inauthself._credentials_auth()File "/Users/ghostlyrics/.pyenv/versions/3.5.3/lib/python3.5/site-packages/gitlab/__init__.py",line216,in_credentials_authr=self.http_post('/session',data)File "/Users/ghostlyrics/.pyenv/versions/3.5.3/lib/python3.5/site-packages/gitlab/__init__.py",line806,inhttp_postpost_data=post_data,files=files,**kwargs)File "/Users/ghostlyrics/.pyenv/versions/3.5.3/lib/python3.5/site-packages/gitlab/__init__.py",line713,inhttp_requestresponse_body=result.content)gitlab.exceptions.GitlabHttpError:404:b'{"error":"404 Not Found"}'self=<gitlab.Gitlabobjectat0x7f28dfd66da0>,verb='post',path='/session',query_data= {'email':'root','password':'some_test_password'},post_data= {},streamed=Falsefiles=None,kwargs= {},sanitized_url=<functionGitlab.http_request.<locals>.sanitized_urlat0x7f28e17879d8>,url='http://localhost/api/v4/session'params= {'email':'root','password':'some_test_password'},opts= {'auth':None,'headers': {'Content-type':'application/json'}},verify=True,timeout=None,req=<Request [post]>defhttp_request(self,verb,path,query_data={},post_data={},streamed=False,files=None,**kwargs):"""Make an HTTP request to the Gitlab server.            Args:                verb (str): The HTTP method to call ('get', 'post', 'put',                            'delete')                path (str): Path or full URL to query ('/projects' or                            'http://whatever/v4/api/projecs')                query_data (dict): Data to send as query parameters                post_data (dict): Data to send in the body (will be converted to                                  json)                streamed (bool): Whether the data should be streamed                **kwargs: Extra data to make the query (e.g. sudo, per_page, page)            Returns:                A requests result object.            Raises:                GitlabHttpError: When the return code is not 2xx            """defsanitized_url(url):parsed=six.moves.urllib.parse.urlparse(url)new_path=parsed.path.replace('.','%2E')returnparsed._replace(path=new_path).geturl()url=self._build_url(path)params=query_data.copy()params.update(kwargs)opts=self._get_session_opts(content_type='application/json')# don't set the content-type header when uploading filesiffilesisnotNone:delopts["headers"]["Content-type"]verify=opts.pop('verify')timeout=opts.pop('timeout')# Requests assumes that `.` should not be encoded as %2E and will make# changes to urls using this encoding. Using a prepped request we can# get the desired behavior.# The Requests behavior is right but it seems that web servers don't# always agree with this decision (this is the case with a default# gitlab installation)req=requests.Request(verb,url,json=post_data,params=params,files=files,**opts)prepped=self.session.prepare_request(req)prepped.url=sanitized_url(prepped.url)result=self.session.send(prepped,stream=streamed,verify=verify,timeout=timeout)if200<=result.status_code<300:returnresulttry:error_message=result.json()['message']except (KeyError,ValueError,TypeError):error_message=result.contentifresult.status_code==401:raiseGitlabAuthenticationError(response_code=result.status_code,error_message=error_message,response_body=result.content)raiseGitlabHttpError(response_code=result.status_code,error_message=error_message,>response_body=result.content)Egitlab.exceptions.GitlabHttpError:404:b'{"error":"404 Not Found"}'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp