Code: Select all
import urequests as requests
response = requests.post("http://jsonplaceholder.typicode.com/posts", data = "some dummy content")
print(response.text)
Code: Select all
import urequests
import ujson as json
refresh_token = "xxxxx"
base_64 = "xxxxx"
class Refresh:
def __init__(self):
self.refresh_token = refresh_token
self.base_64 = base_64
def refresh(self):
query = "https://accounts.spotify.com/api/token"
data={"grant_type": "refresh_token", "refresh_token": refresh_token}
response = urequests.post(url='https://accounts.spotify.com/api/token', data=json.dumps(data),
headers={"Authorization": "Basic " + base_64})
print(response.text)
a = Refresh()
a.refresh()
<!DOCTYPE html>
<html ng-app="accounts" ng-csp>
<head>
<meta charset="utf-8">
<title>Error - Spotify</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<base href="/">
<link rel="icon" href="https://accounts.scdn.co/oauth2/images/ ... 1ac1fa.ico">
<link href="" media="screen" rel="stylesheet">
</head>
<body>
<div class="head">
<a class="spotify-logo" href="/" tabindex="-1" title="Spotify"></a>
</div>
<div class="container-fluid error">
<div class="content">
<h1 class="h1">Error</h1>
<p>
Oops! Something went wrong, please try again or check out our <a href="https://www.spotify.com/help">help area</a>.
</p>
</div>
</div>
<script async defer src="{2}" sp-error='{3}'></script>
</body>
</html>
any idea how to get around this? the only difference I had to make is the json.dumps instead of just headers=headers because it kept returning a "TypeError: object with buffer protocol required" error message. I have looked everywhere but i cant seem to find a solution...
Thank you so much in advance for your help.