Skip to content

Commit

Permalink
fix README code callback samples
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed May 30, 2019
1 parent d322dda commit 589b329
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ If the `Auth0` instance wasn't configured as "OIDC conformant", this call requir
```java
authentication
.login("info@auth0.com", "a secret password", "my-database-connection")
.start(new BaseCallback<Credentials>() {
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials payload) {
//Logged in!
Expand All @@ -329,7 +329,7 @@ When you sign in to a multifactor authentication enabled connection using the `l
```java
authentication
.loginWithOTP("the mfa token", "123456")
.start(new BaseCallback<Credentials>() {
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials payload) {
//Logged in!
Expand All @@ -355,7 +355,7 @@ Step 1: Request the code
```java
authentication
.passwordlessWithEmail("info@auth0.com", PasswordlessType.CODE, "my-passwordless-connection")
.start(new BaseCallback<Credentials>() {
.start(new BaseCallback<Void, AuthenticationException>() {
@Override
public void onSuccess(Void payload) {
//Code sent!
Expand All @@ -375,6 +375,7 @@ Step 2: Input the code
```java
authentication
.loginWithEmail("info@auth0.com", "123456", "my-passwordless-connection")
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials payload) {
//Logged in!
Expand All @@ -393,7 +394,7 @@ authentication
```java
authentication
.signUp("info@auth0.com", "a secret password", "my-database-connection")
.start(new BaseCallback<Credentials>() {
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials payload) {
//Signed Up & Logged in!
Expand All @@ -412,7 +413,7 @@ authentication
```java
authentication
.userInfo("user access_token")
.start(new BaseCallback<Credentials>() {
.start(new BaseCallback<UserProfile, AuthenticationException>() {
@Override
public void onSuccess(UserProfile payload) {
//Got the profile!
Expand Down Expand Up @@ -442,14 +443,14 @@ UsersAPIClient users = new UsersAPIClient(account, "api token");
```java
users
.link("primary user id", "secondary user token")
.start(new BaseCallback<List<UserIdentity>>() {
.start(new BaseCallback<List<UserIdentity>, ManagementException>() {
@Override
public void onSuccess(List<UserIdentity> payload) {
//Got the updated identities! Accounts linked.
}

@Override
public void onFailure(Auth0Exception error) {
public void onFailure(ManagementException error) {
//Error!
}
});
Expand All @@ -460,14 +461,14 @@ users
```java
users
.unlink("primary user id", "secondary user id", "secondary provider")
.start(new BaseCallback<List<UserIdentity>>() {
.start(new BaseCallback<List<UserIdentity>, ManagementException>() {
@Override
public void onSuccess(List<UserIdentity> payload) {
//Got the updated identities! Accounts linked.
}

@Override
public void onFailure(Auth0Exception error) {
public void onFailure(ManagementException error) {
//Error!
}
});
Expand All @@ -481,7 +482,7 @@ users
.start(new BaseCallback<UserProfile, ManagementException>() {
@Override
public void onSuccess(UserProfile payload) {
//Profile
//Profile received
}

@Override
Expand All @@ -503,7 +504,7 @@ users
.start(new BaseCallback<UserProfile, ManagementException>() {
@Override
public void onSuccess(UserProfile payload) {
//Metadata updated
//User Metadata updated
}

@Override
Expand Down Expand Up @@ -542,9 +543,9 @@ The credentials to save **must have** `expires_in` and at least an `access_token
authentication
.login("info@auth0.com", "a secret password", "my-database-connection")
.setScope("openid offline_access")
.start(new BaseCallback<Credentials>() {
.start(new BaseCallback<Credentials, AuthenticationException>() {
@Override
public void onSuccess(Credentials credentials) {
public void onSuccess(Credentials payload) {
//Save the credentials
manager.saveCredentials(credentials);
}
Expand All @@ -567,14 +568,16 @@ boolean authenticated = manager.hasValidCredentials();
Existing credentials will be returned if they are still valid, otherwise the `refresh_token` will be used to attempt to renew them. If the `expires_in` or both the `access_token` and `id_token` values are missing, the method will throw a `CredentialsManagerException`. The same will happen if the credentials have expired and there's no `refresh_token` available.

```java
manager.getCredentials(new BaseCallback<Credentials, CredentialsManagerException>(){
public void onSuccess(Credentials credentials){
//Use the Credentials
}
manager.getCredentials(new BaseCallback<Credentials, CredentialsManagerException>() {
@Override
public void onSuccess(Credentials credentials){
//Use the Credentials
}

@Override
public void onFailure(CredentialsManagerException error){
//Error!
}
//Error!
}
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import com.auth0.android.request.Request;
import com.auth0.android.request.internal.GsonProvider;
import com.auth0.android.request.internal.ManagementErrorBuilder;
import com.auth0.android.request.internal.OkHttpClientFactory;
import com.auth0.android.request.internal.RequestFactory;
import com.auth0.android.result.UserIdentity;
import com.auth0.android.result.UserProfile;
import com.auth0.android.request.internal.OkHttpClientFactory;
import com.auth0.android.util.Telemetry;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
Expand Down

0 comments on commit 589b329

Please sign in to comment.