openid / openid/AppAuth-iOS

Error Domain=org.openid.appauth.general Code=-15 "Nonce mismatch"

Open
#333 5 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Objective-C
Stars
2k
Forks
867
Avg merge
4d 48m
Merged PRs (30d)
1

Description

Describe the bug
Error Domain=org.openid.appauth.general Code=-15 "Nonce mismatch".

Xcode 10
Swift 4.2
AppAuth version 0.95.0

To Reproduce
Steps to reproduce the behavior:

  1. Singing button clicked in the app
  2. Browser opened
  3. enter login credentials
  4. Redirected to app and See error

Expected behavior
Should open the app and get in the app

Smartphone (please complete the following information):

  • Device: iPhone X
  • iOS: iOS 12
  • Browser: Safari

Additional context
`let currentAuthorizationFlow = OIDAuthState.authState(byPresenting: request, presenting: self, callback: { [weak self] (authState, error) in

        guard let strongSelf = self else {
            return
        }
        
        if let authState = authState, let authCode = authState.lastTokenResponse?.idToken {
            if strongSelf.mainViewModel.updateSessionData(accessToken: authCode, authState: authState) {
                strongSelf.mainViewModel.loginAction.apply(()).start()
            } else {
                strongSelf.loginActivityView.isHidden = true
            }
        }
        else {
            print("Authorization error: \(String(describing: error?.localizedDescription))")
            
            if strongSelf.mainViewModel.shouldDefaultToLoyalty {
                let loyaltyPermission = PermissionHandler.loyaltyPermission
                
                for (index, permission) in strongSelf.mainViewModel.stateStorage.userPermissions.enumerated() {
                    if permission.permissionType == .loyalty {
                        strongSelf.mainViewModel.stateStorage.userPermissions[index] = loyaltyPermission
                    }
                }
            }
            
            //Do not show alert in case of general error(org.openid.appauth.general)
            if let generalError = error as NSError?, generalError.code == -4 {
                return
            }
            
            let confirmAction = UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default, handler: {[weak self] (_) in
                self?.dismiss(animated: true, completion: nil)
            })
            //Handle View Hierarchy - Add delay to alert on clicking done button from SafariViewController
            DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
                AlertView.show(alertContents: AlertView.Content(title: NSLocalizedString("Error", comment: ""), message: NSLocalizedString("Unknown Error", comment: ""), buttonTitle: "", actions: [confirmAction]))
            }
        }
    })`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report names no source file or test. Start by reproducing the flow through OIDAuthState.authState(byPresenting:presenting:callback:) with AppAuth 0.95.0 on iOS 12, then trace where the nonce-mismatch error is produced; done means identifying the cause and providing a verified resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, objective-c, swift
Domain
authentication, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.