Я просмотрел огромное количество других сообщений с похожими проблемами, но не смог найти решение.От первой функции calltoken я получаю ответ "[Response]: {URL: https://accounts.spotify.com/login?continue=https%3A%2F%2Faccounts.spotify.com%2Fauthorize%3F%26client_id%3Dd953effa6b32457e8705b2fc31af24e2%26redirect_uri%3DSpotifyPlug%253A%252F%252FreturnAfterLogin%26response_type%3Dcode%26scope%3Dplaylist-modify-private%2520playlist-modify-public%2520playlist-read-private%2520user-library-modify%2520streaming%26state%3D34fFs29kd09} {Код состояния: 200, я скопировал URL во функцию вызова второго токена, но получил недопустимый клиент. Любая помощьбудет принята с благодарностью.
func callToken() {
let parameters = ["client_id" : str1,
"response_type" : "code",
"redirect_uri" : "SpotifyPlug://returnAfterLogin",
"scope" : "playlist-modify-private playlist-modify-public playlist-read-private user-library-modify streaming"]
Alamofire.request("https://accounts.spotify.com/authorize?", method: .get, parameters: parameters).responseString{ response in
debugPrint(response)
}
timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(getToken2), userInfo: nil, repeats: false)
}
@objc func getToken2(){
str1 = str1.toBase64()
str2 = str2.toBase64()
let Authorization = ["Basic "+str1:str2]
let parameters2 = ["grant_type" : "authorization_code",
"code" :"https://accounts.spotify.com/login?continue=https%3A%2F%2Faccounts.spotify.com%2Fauthorize%3F%26client_id%3Dd953effa6b32457e8705b2fc31af24e2%26redirect_uri%3DSpotifyPlug%253A%252F%252FreturnAfterLogin%26response_type%3Dcode%26scope%3Dplaylist-modify-private%2520playlist-modify-public%2520playlist-read-private%2520user-library-modify%2520streaming%26state%3D34fFs29kd09","redirect_uri" : "SpotifyPlug://returnAfterLogin"]
Alamofire.request("https://accounts.spotify.com/api/token", method: .post, parameters: parameters2, headers: Authorization).responseJSON(completionHandler: {
response in
print(response)
if let result = response.result.value {
let jsonData = result as! NSDictionary
AuthService.instance.tokenId = jsonData.value(forKey: "access_token") as? String
print(AuthService.instance.tokenId!)
}
})
}`