Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
826 views
in Technique[技术] by (71.8m points)

oauth 2.0 - GoogleSignIn (iOS) getTokensWithHandler doesn't call its closure after token has expired

I am using Google Sign-In 5.0.2 with a Swift 4 iOS app. Here is my code to get a current id Token:

GIDSignIn.sharedInstance()?.currentUser?.authentication.getTokensWithHandler({ gidAuth, error in
            if let error = error {
                completion(.failure(error))
            } else if let token = gidAuth?.idToken {
                completion(.success(token))
            } else {
                assertionFailure("shouldn't have come here")
            }
        })

This works fine when I launch the app. But if I leave the app running for an hour (to let the id token expire), then the next time getTokensWithHandler is called, it will not call my closure. Subsequent calls to getTokensWithHandler will once again call my closure.

I would like it to behave consistently so that my closure is always called, even if the token needs to be refreshed.

Anyone have any ideas on what I need to do to achieve this?

question from:https://stackoverflow.com/questions/65892057/googlesignin-ios-gettokenswithhandler-doesnt-call-its-closure-after-token-has

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...