Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh dev doc improve #122

Merged
merged 4 commits into from
Mar 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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