From 3b976fed0b4bf6a2ebb2b370c02a059d9e04784e Mon Sep 17 00:00:00 2001 From: Yotam Madem Date: Sun, 18 Mar 2018 15:20:49 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3154a40..31ceedb 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,13 +100,30 @@ 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 Make sure to set **Allow users to sign up and reset their password** to **ON**, in the settings for Cloud Directory. -Use LoginWidget class to start the sign up flow. +Use Widget class to start the sign up flow. ```swift class delegate : AuthorizationDelegate { public func onAuthorizationSuccess(accessToken: AccessToken?, identityToken: IdentityToken?, refreshToken: RefreshToken?, response:Response?) { From 8f9896256356f7010b03f7fe70233a29905c34f1 Mon Sep 17 00:00:00 2001 From: Yotam Madem Date: Sun, 18 Mar 2018 15:25:56 +0200 Subject: [PATCH 2/4] Update AppID.swift --- Source/BluemixAppID/api/AppID.swift | 6 ++++++ 1 file changed, 6 insertions(+) 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, From 9d957ffede3d083432c5bce1fd79267348d00b47 Mon Sep 17 00:00:00 2001 From: Yotam Madem Date: Sun, 18 Mar 2018 15:27:39 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 31ceedb..44421a4 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ It is recommended to store the refresh token locally such that it will be possib Make sure to set **Allow users to sign up and reset their password** to **ON**, in the settings for Cloud Directory. -Use Widget class to start the sign up flow. +Use Login Widget class to start the sign up flow. ```swift class delegate : AuthorizationDelegate { public func onAuthorizationSuccess(accessToken: AccessToken?, identityToken: IdentityToken?, refreshToken: RefreshToken?, response:Response?) { From 24daeb24d2eecbfded83fab33a68c72ea144ed7f Mon Sep 17 00:00:00 2001 From: Yotam Madem Date: Sun, 18 Mar 2018 15:28:24 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44421a4..2a1fb1d 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ It is recommended to store the refresh token locally such that it will be possib Make sure to set **Allow users to sign up and reset their password** to **ON**, in the settings for Cloud Directory. -Use Login Widget class to start the sign up flow. +Use LoginWidget class to start the sign up flow. ```swift class delegate : AuthorizationDelegate { public func onAuthorizationSuccess(accessToken: AccessToken?, identityToken: IdentityToken?, refreshToken: RefreshToken?, response:Response?) {