Ich versuche, AppAuth in iOS zu implementieren. Grundlegende Implementierung wurde durchgeführt. scheint alles gut zu funktionieren. aber ich erhalte das Token nicht wie erwartet. im immer Fehler Error Domain=org.openid.appauth.general Code=-4
OAuth Fehler Allgemeiner Code 4 Swift - AppAuth für iOS
let authorizationEndpoint : NSURL = NSURL(string: "https://accounts.google.com/o/oauth2/v2/auth")!
let tokenEndpoint : NSURL = NSURL(string: "https://www.googleapis.com/oauth2/v4/token")!
let configuration = OIDServiceConfiguration(authorizationEndpoint: authorizationEndpoint as URL, tokenEndpoint: tokenEndpoint as URL)
let request = OIDAuthorizationRequest.init(configuration: configuration, clientId: "<MyTOKEN>", scopes: [OIDScopeOpenID], redirectURL: URL(string: "http://127.0.0.1:9004")!, responseType: OIDResponseTypeCode, additionalParameters: nil)
let appDelegate = UIApplication.shared.delegate as! AppDelegate
// appDelegate.currentAuthorizationFlow
appDelegate.currentAuthorizationFlow = OIDAuthState.authState(byPresenting: request, presenting: self, callback: { (authState, error) in
if((authState) != nil){
print("Got authorization tokens. Access token: \(authState?.lastTokenResponse?.accessToken)")
}else{
print("Authorization error \(error?.localizedDescription)")
}
})
Sie clientSecret mit der Bitte – Govaadiyo
Ah no gesetzt hat. es wurde nicht im Dokument "https: // github.com/openid/AppAuth-iOS" erwähnt, wie das geht? –
fand es im Dokument, aber 'client_secret \t Das Client-Geheimnis von der API-Konsole erhalten. Dieser Wert wird für Clients, die als Android-, iOS- oder Chrome-Anwendungen registriert sind, nicht benötigt, da er für iOS nicht benötigt wird. –