Skip to content

Commit

Permalink
Merge pull request #122 from ibm-cloud-security/refresh-dev-doc-improve
Browse files Browse the repository at this point in the history
Refresh dev doc improve
  • Loading branch information
yotammadem committed Mar 18, 2018
2 parents dfc1b2a + 24daeb2 commit d924cf4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Expand Up @@ -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
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions Source/BluemixAppID/api/AppID.swift
Expand Up @@ -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,
Expand Down

0 comments on commit d924cf4

Please sign in to comment.