nxtbgthng / OAuth2Client

Client library for OAuth2 (currently built against draft 10 of the OAuth2 spec)
855 stars 217 forks source link

NXOAuth2Store Configuration lost after app restart #190

Open tekatool opened 9 years ago

tekatool commented 9 years ago

My app creates an account successfully after OAuth2 flow. When I stop the app and restart, it fails when I try to use NXOAuth2Request SignedURLRequest. Looks like the config info is not persisted ?

I am using iOS 8 in simulator.

Including the trace below...Any prompt help is really appreciated...

terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'No token or no authorize URL' *\ First throw call stack: ( 0 CoreFoundation 0x000000010f248c65 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010fad0bb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010f248aca +[NSException raise:format:arguments:] + 106 3 Foundation 0x000000010f6e598f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 OAuth2Client 0x000000010f0e1788 -[NXOAuth2Client initWithClientID:clientSecret:authorizeURL:tokenURL:accessToken:tokenType:keyChainGroup:keyChainAccessGroup:persistent:delegate:] + 600 5 OAuth2Client 0x000000010f0cd5d8 -[NXOAuth2Account oauthClient] + 1000 6 OAuth2Client 0x000000010f0d72df -[NXOAuth2Request signedURLRequest] + 303 7 OAuthTestApp1 0x000000010dd52164 -[TestPRWebViewController buildRequest] + 500

Thanks

toto commented 9 years ago

The only thing that is persistent are the access tokens (in the keychain). You need to make the calls to NXAccountStore each time the app starts before anything. I recommend doing that in +initialize of your app delegate.