diff --git a/Sources/OAuth2Client/NXOAuth2AccountStore.m b/Sources/OAuth2Client/NXOAuth2AccountStore.m index 64df5be9..d28ca795 100644 --- a/Sources/OAuth2Client/NXOAuth2AccountStore.m +++ b/Sources/OAuth2Client/NXOAuth2AccountStore.m @@ -485,7 +485,7 @@ - (void)oauthClientNeedsAuthentication:(NXOAuth2Client *)client; #endif } -- (void)oauthClientDidGetAccessToken:(NXOAuth2Client *)client; +- (void)oauthClientDidGetAccessToken:(NXOAuth2Client *)client { NSString *accountType; @synchronized (self.pendingOAuthClients) { @@ -498,6 +498,31 @@ - (void)oauthClientDidGetAccessToken:(NXOAuth2Client *)client; [self addAccount:account]; } +- (void)oauthClientDidRefreshAccessToken:(NXOAuth2Client *)client +{ + NXOAuth2Account* foundAccount = nil; + + @synchronized (self.accountsDict) + { + for (NXOAuth2Account* account in self.accounts) + { + if (account.oauthClient == client) + { + foundAccount = account; + break; + } + } + } + + foundAccount.accessToken = client.accessToken; + NSDictionary *userInfo = [NSDictionary dictionaryWithObject: foundAccount + forKey: NXOAuth2AccountStoreNewAccountUserInfoKey]; + + [[NSNotificationCenter defaultCenter] postNotificationName:NXOAuth2AccountStoreAccountsDidChangeNotification + object:self + userInfo:userInfo]; +} + - (void)addAccount:(NXOAuth2Account *)account; { @synchronized (self.accountsDict) {