Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
Please see below the most popular frequently asked questions.
Loading article...
Loading faqs...
Please see below the current ongoing issues which are under investigation.
Loading issue...
Loading ongoing issues...
Device
(iPhone 13)
Operating System
iOS
Hello,
I am using the Authorization Code Flow to obtain a token and trying to make a request to get recently played tracks (Get Recently Played Tracks). However, I am encountering a 403 error.
The first time I made this request, it succeeded and I was able to retrieve the recently played tracks
The response body indicates: "Check settings on developer.spotify.com/dashboard, the user may not be registered."
Could you please assist me in resolving this issue?
Thank you.
Hi jasperjarecki, welcome back to the Community!
Are you trying to use it with your developer account or another?
And could you please add a code block with your code, so I can help you find the bug?
You can insert a code block by first clicking on …, and then on </>.
enum SearchMusicAPI {
case searchMusic(byName: String, limit: Int, type: String, offset: Int)
case getRecently(limit: Int)
}
extension SearchMusicAPI: TargetType {
enum Parameters {
static let limit = "limit"
}
var baseURL: URL {
guard let url = Constants.API.baseURL else { fatalError() }
return url
}
var path: String {
switch self {
case .getRecently: return "/v1/me/player/recently-played"
}
}
var method: Moya.Method { .get }
var sampleData: Data { return "".data(using: .utf8)! }
var headers: [String: String]? {
switch self {
case .getRecently:
return ["Authorization" : "Bearer " + (UserDefaults.standard.string(forKey: "token") ?? ""),
"Content-Type" : "application/json",
"Accept" : "application/json"]
}
}
var task: Task {
switch self {
case let .getRecently(limit):
return .requestParameters(parameters: [Parameters.limit : limit],
encoding: URLEncoding.default)
}
}
}
I am adding code with the token retrieval service, but the code keeps getting deleted.
Hi jasperjarecki, thanks for posting your code.
I don't see how you acquired the Bearer token. I think there is a mistake in the step of getting it.
That is inconvenient that it keeps getting deleted. Thank you providing screenshots anyway.
I don't see any obvious bugs. As you noticed the first time running your code, it worked.
Does the Bearer token get stored anywhere at your machine? And do you test this app with your developer account, or another?
Hey there you, Yeah, you! 😁 Welcome - we're glad you joined the Spotify Community! While you here, let's have a fun game and get…