Saturday, May 4, 2024
HomeiOS Developmentswift - Error 400: invalid_request for iOS google Register

swift – Error 400: invalid_request for iOS google Register


I’ve an iOS app that has Google Cloud SignIn utilizing Firebase, however when opening the net to register, I get the next errors:

We can not confirm the authenticity of this app. Please contact the
developer. Token failed.

In case you are a ******* developer, see the error particulars.

Error 400: invalid_request

Request particulars: response_type=code code_challenge_method=S256
nonce=bRNSXpeJTQfPJn435Pn9C0niL5NIRzkxtb1BAIsXqu0 device_os=iOS 17.4.1
client_id=541903925667-nnvn5cctvima77nh4elc81schetiv4ok.apps.googleuser
content material.com emm_support=1 gpsdk=gid-7.1.0 gidenv=ios
state=-KR22DP2ZWwf9bXZRWm96HGQjVt2-8KxEZ1GHYxAu3g
redirect_uri=com.googleusercontent.apps.541903925667-nnvn5cctvima77nh4elc81schetiv4ok:/oauth2callback
code_challenge=4ryryshF3lScPX6fJ-MSWR0AmgMsUM_OlhhFoo9P3MU
include_granted_scopes=true access_type=offline
scope=https://www.googleapis. com/auth/userinfo.electronic mail
https://www.googleapis. com/auth/userinfo.profile openid

Result on Google SignIn iOS

I checked the credentials of the GoogleService-Information.plist file that I downloaded from Firebase and each the CLIENT_ID and the REVERSED_CLIENT_ID are the identical as these in my Google Cloud configuration, additionally, the REVERSED_CLIENT_ID is identical because the URL Sort that I’ve in Xcode

URL Types on Xcode

In my Google Cloud Platform dashboard I’ve this config:
Google Cloud Platform on Credentials Section

Inside my iOS Shopper for ******* (auth created by Google Service) I’ve this config witch are equal to my GoogleService-info file
iOS Client config

Any concept how I can resolve this error ? I take away and added once more my iOS app on Firebase however the issue nonetheless continues

My code to register with Google are:

func sigInWithGoogle(completion: @escaping (Bool, Error?) -> Void) {
        guard let rootViewController = UIApplication.shared.keyWindow?.rootViewController else { return }
        
        guard let clientID = FirebaseApp.app()?.choices.clientID else { return }
        let config = GIDConfiguration(clientID: clientID)
        GIDSignIn.sharedInstance.configuration = config
        
        GIDSignIn.sharedInstance.signIn(withPresenting: rootViewController) { signInResult, error in
            if let error = error {
                completion(false, error)
                print("Error loggin with Google: (error.localizedDescription)")
                return
            }
            
            guard let authentication = signInResult?.consumer, let idToken = authentication.idToken else {
                return
            }
            
            let idTokenString = idToken.tokenString
            let credential = GoogleAuthProvider.credential(withIDToken: idTokenString, accessToken: signInResult?.consumer.idToken?.tokenString ?? "")
            Auth.auth().signIn(with: credential) { authResult, error in
                if let error = error {
                    completion(false, error)
                    return
                }
                guard let consumer = authResult?.consumer else { return }
                AnalyticsManager.shared.logEvent(.loginWithGoogle)
                guard let title = consumer.displayName else { return }
                DispatchQueue.fundamental.async {
                    self.defaults.set(title, forKey: Constants.UserDefaultsValues.userFirstName)
                }
                completion(true, nil)
            }
        }
    }



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments