As a beginner in coding, I am trying to create user login by using Twitch API on my WebView in Xcode. I manage to get user to sign and authorize however, screen goes all white and don't know what to do afterwards. Following is the code that use,
let twitchApiUrl = "https://id.twitch.tv/oauth2/authorize?client_id=(clientId)&redirect_uri=(registeredUri)&response_type=token+id_token&scope=openid"
let registeredUri = "https://loginpage"
let clientId = "yu4sqhnxv3qazgpfecrhtsxn2k2ttm"
class ViewController: UIViewController, WKNavigationDelegate {
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func twitchLogin(_ sender: Any) {
// WebView Access
webView = WKWebView()
webView.navigationDelegate = self
view = webView
// Twitch API Request
let request = NSURLRequest(url: NSURL(string: twitchApiUrl)! as URL)
webView.load(request as URLRequest)
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
print("loaded")
}
}
I believe the problem is, my redirect URI is not sending it back to the application after authorisation. I greatly appreciate if someone can clarify the issue.
Thanks
question from:
https://stackoverflow.com/questions/65872504/twitch-api-authentication-using-wkwebview 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…