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

API v2 - Authenticate Fail #7777

Closed
luciofsl opened this issue Feb 24, 2020 · 4 comments · Fixed by #7842
Closed

API v2 - Authenticate Fail #7777

luciofsl opened this issue Feb 24, 2020 · 4 comments · Fixed by #7842
Labels

Comments

@luciofsl
Copy link

I'm trying to use the APIv2 but the authorization fails.
What is wrong with my resquests?

#############Request#############
POST /api/v2/authenticate HTTP/1.1
Host: 192.168.17.204:8081
User-Agent: FlexGet/3.1.15 (www.flexget.com)
Accept-Encoding: gzip, deflate
Accept: /
Connection: keep-alive
Content-Length: 46
Content-Type: application/json

{"username": "medusa", "password": "password"}

#############Response#############
HTTP/1.1 200 OK
Server: TornadoServer/5.1.1
Content-Type: application/json; charset=UTF-8
Date: Thu, 06 Feb 2020 15:58:10 GMT
X-Medusa-Server: 0.3.11
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, Accept, Authorization, Content-Type, X-Requested-With, X-CSRF-Token, X-Api-Key, X-Medusa-Server
Access-Control-Allow-Methods: OPTIONS, POST
Content-Length: 297
Vary: Accept-Encoding

{"token": "b'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNZWR1c2EgMC4zLjExIiwiaWF0IjoxNTgxMDA0NjkwLCJqdGkiOiJwZ25rdXI2WDZrOEdRZjBleGc1OCIsImV4cCI6MTU4MTA5MTA5MCwidXNlcm5hbWUiOiJtZWR1c2EiLCJhcGlLZXkiOiI3NWVhYWM4ZTY3YzRhNWIyODQ5MmZmZjk3ODRjNDZhMCJ9.LU7fdfIU9wFVvg_nsJpPzUgOUQ8juPR0t6_uACfr3Zc'"}

#############Request#############
GET /api/v2/series?limit=1000 HTTP/1.1
Host: 192.168.17.204:8081
User-Agent: FlexGet/3.1.15 (www.flexget.com)
Accept-Encoding: gzip, deflate
Accept: /
Connection: keep-alive
authorization: Bearer b'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNZWR1c2EgMC4zLjExIiwiaWF0IjoxNTgxMDA0NjkwLCJqdGkiOiJwZ25rdXI2WDZrOEdRZjBleGc1OCIsImV4cCI6MTU4MTA5MTA5MCwidXNlcm5hbWUiOiJtZWR1c2EiLCJhcGlLZXkiOiI3NWVhYWM4ZTY3YzRhNWIyODQ5MmZmZjk3ODRjNDZhMCJ9.LU7fdfIU9wFVvg_nsJpPzUgOUQ8juPR0t6_uACfr3Zc'

#############Response#############
HTTP/1.1 401 Unauthorized
Server: TornadoServer/5.1.1
Content-Type: application/json; charset=UTF-8
Date: Thu, 06 Feb 2020 15:58:10 GMT
X-Medusa-Server: 0.3.11
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, Accept, Authorization, Content-Type, X-Requested-With, X-CSRF-Token, X-Api-Key, X-Medusa-Server
Access-Control-Allow-Methods: OPTIONS, GET, POST, PATCH, DELETE
Content-Length: 27
Vary: Accept-Encoding

{"error": "Invalid token."}

@triage-new-issues triage-new-issues bot added the triage Untriaged issue label Feb 24, 2020
@p0psicles
Copy link
Contributor

You need to remove the b' part. So only use what's in the single quotes.

@p0psicles
Copy link
Contributor

p0psicles commented Feb 24, 2020

Don't why it's giving you the literal binary string back.

@luciofsl
Copy link
Author

That's it!
I just change the medusa pluging code in flexget and now is working.
Many tks.

        api_key = task.requests.post('{}/authenticate'.format(base_url), json=body_auth).json()[
            'token'
        ]
        api_key = api_key[2:-1]

        headers = {'authorization': 'Bearer ' + api_key}

@medariox
Copy link
Contributor

Fixed with #7842

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

Successfully merging a pull request may close this issue.

3 participants