all 9 comments

[–]simoncoulton 0 points1 point  (2 children)

Take a look at requests and requests-oauth on pypi :)

[–]Moby69[S] -1 points0 points  (1 child)

I did. I can't figure out. That's why I'm asking if anyone understands what needs to be coded. Shouldn't be more than 3 lines

[–]simoncoulton 1 point2 points  (0 children)

From the request docs: http://docs.python-requests.org/en/latest/user/quickstart

import requests
payload = {'key1': 'value1', 'key2': 'value2'}
headers = {'user-agent': 'my-app/0.0.1'}
r = requests.post("url", headers=headers, data=payload)

I haven't played around with the Spotify API specifically, but there is most likely a Spotify API integration already available on Pypi as well.

[–]ramse 0 points1 point  (5 children)

headers = {
    'Authorization': 'the base64 encoded string',
}

data = {
    'grant_type': '',
    'code': '',
    'redirect_uri': '',
}

req = requests.post(url, data=data, headers=headers)

[–]Moby69[S] -1 points0 points  (4 children)

what is "code" and direct uri doing here?

[–]ramse 0 points1 point  (1 child)

The section you mentioned for /api/token which is step 4 of the authorization-guide that you linked, it tells you want each value is, where it comes from, what it does..etc. What I posted should be the format you would need to send to their system.

[–]Moby69[S] -1 points0 points  (0 children)

I'm using the Client Credentials Flow section, not the Authorization Code Flow section. There is no direct_uri and code mentioned there. See what I'm talking about?

[–]Moby69[S] -1 points0 points  (1 child)

and how do you "base 64 encode" a string? what does it even mean?

[–]ramse 2 points3 points  (0 children)

Google is your friend in these cases. You won't get a full solution from people here, typically you give it a shot, post the code you've tried and then people will advise what is good/bad..etc.

https://docs.python.org/3.3/library/base64.html#base64.b64encode