I am trying to use Spotify API. But as the given auth token expires every hour, so I have to post a request to API to get a new one. I found a code on the official website that shows how to do it.
var client_id = 'CLIENT_ID';
var client_secret = 'CLIENT_SECRET';
var authOptions = {
url: 'https://accounts.spotify.com/api/token',
headers: {
'Authorization': 'Basic ' + (new Buffer(client_id + ':' + client_secret).toString('base64'))
},
form: {
grant_type: 'client_credentials'
},
json: true
};
request.post(authOptions, function(error, response, body) {
if (!error && response.statusCode === 200) {
var token = body.access_token;
}
});
But I am new to retrofit and I don't know any js. So I don't know how can I convert this code to kotlin. can anyone help me out?