I am really new to programming and restAPIs. Please try to give a detailed explaination and if possible mention the code in swift.
When the user clicks the login button on my application, he is being redirected to the spotify authorisation link in the safari app. When he enters his login details then he is being redirected back to my application screen. I have created a redirect uri for redirection back the user to my app(lets call it myUri://
). Now when the user gets back to my application, the uri should have some code and status(eg myUri/code=qqWeerT06-qQr
).
But the question is how and where should I get access to the redirected uri containing code?
Please help. I have searched everywhere but I am not able to get the solution. I cant focus on any other work and just want to complete the OAuth 2 process and proceed my other work.
I have created a simple button, when clicked lets the user to the authorisation link where user log in his details.
Spotify has a really nice iOS SDK for handling authorization and music playback through Spotify: https://developer.spotify.com/technologies/spotify-ios-sdk/
Their tutorial is in Objective-C but I'm sure there are plenty others out there that walk you through step-by-step from registering your app with Spotify to completing the auth process.
However, if you don't want to go down that route then perhaps try intercepting the callback in
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
and see if you're getting the proper response.
(also be sure that you have rgistered your apps custom url scheme in your Info.plist
)