iOSでAppAuthを実装しようとしています。基本的な実装が行われています。うまく動作しているようです。期待どおりにトークンを受け取っていません。イム取得エラーError Domain=org.openid.appauth.general Code=-4
OAuthエラー一般コード4 Swift - AppAuth for 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)")
}
})
はあなたが要求 – Govaadiyo
なしああでclientSecretを設定しなかったことができる方法です。それはドキュメント 'https:// github.com/openid/AppAuth-iOS'には言及されていませんでしたか? –
はドキュメント内でそれを見つけましたが、 'client_secret \t APIコンソールから取得したクライアントシークレットです。この値は、Android、iOS、またはChromeアプリケーションとして登録されたクライアントには必要ありません。 –