diff --git a/README.md b/README.md index 3154a40..2a1fb1d 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ AppID.sharedInstance.loginWidget?.launch(delegate: delegate()) ## Managing Cloud Directory with the iOS Swift SDK -### Login using Resource Owner Password +### Sign in using Resource Owner Password You can obtain access token and id token by supplying the end user's username and the end user's password. ```swift @@ -100,7 +100,24 @@ You can obtain access token and id token by supplying the end user's username an AppID.sharedInstance.signinWithResourceOwnerPassword(username: username, password: password, delegate: delegate()) ``` - {: codeblock} + +### Sign in with refresh token + +It is recommended to store the refresh token locally such that it will be possible to sign in with the refresh token without requiring the user to type his credentials again. + ```swift + class delegate : TokenResponseDelegate { + public func onAuthorizationSuccess(accessToken: AccessToken?, identityToken: IdentityToken?, refreshToken: RefreshToken?, response:Response?) { + //User authenticated + } + + public func onAuthorizationFailure(error: AuthorizationError) { + //Exception occurred + } + } + + AppID.sharedInstance.signInWithRefreshToken(refreshTokenString: refreshTokenString, delegate: delegate()) + ``` + ### Sign Up diff --git a/Source/BluemixAppID/api/AppID.swift b/Source/BluemixAppID/api/AppID.swift index f3e6722..07d4a20 100644 --- a/Source/BluemixAppID/api/AppID.swift +++ b/Source/BluemixAppID/api/AppID.swift @@ -58,6 +58,12 @@ public class AppID { oauthManager?.authorizationManager?.signinWithResourceOwnerPassword(accessTokenString: accessTokenString, username: username, password: password, tokenResponseDelegate: tokenResponseDelegate) } + /** + Obtain new access and identity tokens using a refresh token. + + Note that the identity itself (user name/details) will not be refreshed by this operation, + it will remain the same identity but in a new token (new expiration time) + */ public func signinWithRefreshToken(refreshTokenString:String? = nil, tokenResponseDelegate:TokenResponseDelegate) { oauthManager?.authorizationManager?.signinWithRefreshToken( refreshTokenString: refreshTokenString,