Skip to content

Commit 9f6af57

Browse files
authored
Merge pull request #51 from auth0/add-refresh-token
Add renew authentication endpoint
2 parents 83ee983 + 9d56b38 commit 9f6af57

24 files changed

Lines changed: 218 additions & 137 deletions

README.md

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The Auth0 Authentication API and User's Management API are available for Android
3636

3737
The implementation is based on the [Authentication API Docs](https://auth0.com/docs/api/authentication).
3838

39-
Create a new `AuthAPI` instance by providing the client data from the [dashboard](https://manage.auth0.com/#/clients).
39+
Create an `AuthAPI` instance by providing the client data from the [dashboard](https://manage.auth0.com/#/clients).
4040

4141
```java
4242
AuthAPI auth = new AuthAPI("{YOUR_DOMAIN}", "{YOUR_CLIENT_ID}", "{YOUR_CLIENT_SECRET}");
@@ -71,7 +71,7 @@ String url = auth.logoutUrl("https://me.auth0.com/home", true)
7171
```
7272

7373
### UserInfo - /userinfo
74-
Creates a new request to get the user information associated to a given access token. This will only work if the token has been granted the `openid` scope.
74+
Creates a request to get the user information associated to a given access token. This will only work if the token has been granted the `openid` scope.
7575

7676
`Request<UserInfo> userInfo(String accessToken)`
7777

@@ -89,7 +89,7 @@ try {
8989
```
9090

9191
### Reset Password - /dbconnections/change_password
92-
Creates a new request to reset the user's password. This will only work for db connections.
92+
Creates a request to reset the user's password. This will only work for db connections.
9393

9494
`Request resetPassword(String email, String connection)`
9595

@@ -107,7 +107,7 @@ try {
107107

108108

109109
### Sign Up - /dbconnections/signup
110-
Creates a new request to create a new user. Up to 10 additional Sign Up fields can be added to the request. This will only work for db connections.
110+
Creates a request to create a user. Up to 10 additional Sign Up fields can be added to the request. This will only work for db connections.
111111

112112
`SignUpRequest signUp(String email, String username, String password, String connection)`
113113

@@ -131,7 +131,7 @@ try {
131131

132132
### Exchange the Authorization Code - /oauth/token
133133

134-
Creates a new request to exchange the `code` previously obtained by calling the /authorize endpoint. The redirect uri must be the one sent in the /authorize call.
134+
Creates a request to exchange the `code` previously obtained by calling the /authorize endpoint. The redirect uri must be the one sent in the /authorize call.
135135

136136
`AuthRequest exchangeCode(String code, String redirectUri)`
137137

@@ -151,7 +151,7 @@ try {
151151

152152
### Log In with Password - /oauth/token
153153

154-
Creates a new request to log in the user with `username` and `password`. The connection used is the one defined as "Default Directory" in the account settings.
154+
Creates a request to log in the user with `username` and `password`. The connection used is the one defined as "Default Directory" in the account settings.
155155

156156
`AuthRequest login(String emailOrUsername, String password)`
157157

@@ -171,7 +171,7 @@ try {
171171

172172
### Log In with Password Realm - /oauth/token
173173

174-
Creates a new request to log in the user with `username` and `password` using the Password Realm.
174+
Creates a request to log in the user with `username` and `password` using the Password Realm.
175175

176176
`AuthRequest login(String emailOrUsername, String password, String realm)`
177177

@@ -191,7 +191,7 @@ try {
191191

192192
### Request Token for Audience - /oauth/token
193193

194-
Creates a new request to get a Token for the given Audience.
194+
Creates a request to get a Token for the given Audience.
195195

196196
`AuthRequest requestToken(String audience)`
197197

@@ -210,7 +210,7 @@ try {
210210

211211
### Revoke Refresh Token
212212

213-
Creates a new request to revoke an existing Refresh Token.
213+
Creates a request to revoke an existing Refresh Token.
214214

215215
`Request<Void> revokeToken(String refreshToken)`
216216

@@ -226,12 +226,30 @@ try {
226226
}
227227
```
228228

229+
### Renew Authentication
230+
231+
Creates a request to renew the authentication and get fresh new credentials using a valid Refresh Token.
232+
233+
`AuthRequest renewAuth(String refreshToken)`
234+
235+
Example:
236+
```java
237+
AuthRequest request = auth.renewAuth("nisd1h9dks1doWJOsaf");
238+
try {
239+
TokenHolder holder = request.execute();
240+
} catch (APIException exception) {
241+
// api error
242+
} catch (Auth0Exception exception) {
243+
// request error
244+
}
245+
```
246+
229247

230248
## Management API
231249

232250
The implementation is based on the [Management API Docs](https://auth0.com/docs/api/management/v2).
233251

234-
Create a new `ManagementAPI` instance by providing the domain from the [client dashboard](https://manage.auth0.com/#/clients) and the API Token. Click [here](https://auth0.com/docs/api/management/v2#!/Introduction/Getting_an_API_token) for more information on how to obtain a valid API Token.
252+
Create a `ManagementAPI` instance by providing the domain from the [client dashboard](https://manage.auth0.com/#/clients) and the API Token. Click [here](https://auth0.com/docs/api/management/v2#!/Introduction/Getting_an_API_token) for more information on how to obtain a valid API Token.
235253

236254
```java
237255
ManagementAPI mgmt = new ManagementAPI("{YOUR_DOMAIN}", "{YOUR_API_TOKEN}");
@@ -259,7 +277,7 @@ The Management API is divided into different entities. Each of them have the lis
259277

260278
#### List
261279

262-
Creates a new request to list the Users. An API Token with scope `read:users` is needed. If you want the identities.access_token property to be included, you will also need the scope `read:user_idp_tokens`.
280+
Creates a request to list the Users. An API Token with scope `read:users` is needed. If you want the identities.access_token property to be included, you will also need the scope `read:user_idp_tokens`.
263281
You can pass an optional Filter to narrow the results in the response.
264282

265283
`Request<UsersPage> list(UserFilter filter)`
@@ -279,7 +297,7 @@ try {
279297

280298
#### Get
281299

282-
Creates a new request to get a User. An API Token with scope `read:users` is needed. If you want the identities.access_token property to be included, you will also need the scope `read:user_idp_tokens`.
300+
Creates a request to get a User. An API Token with scope `read:users` is needed. If you want the identities.access_token property to be included, you will also need the scope `read:user_idp_tokens`.
283301
You can pass an optional Filter to narrow the results in the response.
284302

285303
`Request<User> get(String userId, UserFilter filter)`
@@ -299,7 +317,7 @@ try {
299317

300318
#### Create
301319

302-
Creates a new request to create a new User. An API Token with scope `create:users` is needed.
320+
Creates a request to create a User. An API Token with scope `create:users` is needed.
303321

304322
`Request<User> create(User user)`
305323

@@ -318,7 +336,7 @@ try {
318336

319337
#### Delete
320338

321-
Creates a new request to delete a User. An API Token with scope `delete:users` is needed.
339+
Creates a request to delete a User. An API Token with scope `delete:users` is needed.
322340

323341
`Request delete(String userId)`
324342

@@ -336,7 +354,7 @@ try {
336354

337355
#### Update
338356

339-
Creates a new request to update a User. An API Token with scope `update:users` is needed. If you're updating app_metadata you'll also need `update:users_app_metadata` scope.
357+
Creates a request to update a User. An API Token with scope `update:users` is needed. If you're updating app_metadata you'll also need `update:users_app_metadata` scope.
340358

341359
`Request<User> update(String userId, User user)`
342360

@@ -355,7 +373,7 @@ try {
355373

356374
#### Get Guardian Enrollments
357375

358-
Creates a new request to list the User's Guardian Enrollments. An API Token with scope `read:users` is needed.
376+
Creates a request to list the User's Guardian Enrollments. An API Token with scope `read:users` is needed.
359377

360378
`Request<List<Enrollment>> getEnrollments(String userId)`
361379

@@ -373,7 +391,7 @@ try {
373391

374392
#### Get Log Events
375393

376-
Creates a new request to list the User's Log Events. An API Token with scope `read:logs` is needed.
394+
Creates a request to list the User's Log Events. An API Token with scope `read:logs` is needed.
377395
You can pass an optional Filter to narrow the results in the response.
378396

379397
`Request<LogEventsPage> getLogEvents(String userId, LogEventFilter filter)`
@@ -394,7 +412,7 @@ try {
394412

395413
#### Delete Multifactor Provider
396414

397-
Creates a new request to delete the User's Multifactor Provider. An API Token with scope `update:users` is needed.
415+
Creates a request to delete the User's Multifactor Provider. An API Token with scope `update:users` is needed.
398416

399417
`Request deleteMultifactorProvider(String userId, String provider)`
400418

@@ -412,7 +430,7 @@ try {
412430

413431
#### Rotate Recovery Code
414432

415-
Creates a new request to rotate the User's Recovery Code. An API Token with scope `update:users` is needed.
433+
Creates a request to rotate the User's Recovery Code. An API Token with scope `update:users` is needed.
416434

417435
`Request<RecoveryCode> rotateRecoveryCode(String userId)`
418436

@@ -430,7 +448,7 @@ try {
430448

431449
#### Link Identities
432450

433-
Creates a new request to link two User identities. An API Token with scope `update:users` is needed.
451+
Creates a request to link two User identities. An API Token with scope `update:users` is needed.
434452

435453
`Request<List<Identity>> linkIdentity(String primaryUserId, String secondaryUserId, String provider, String connectionId)`
436454

@@ -448,7 +466,7 @@ try {
448466

449467
#### Un-Link Identities
450468

451-
Creates a new request to un-link two User identities. An API Token with scope `update:users` is needed.
469+
Creates a request to un-link two User identities. An API Token with scope `update:users` is needed.
452470

453471
`Request<List<Identity>> unlinkIdentity(String primaryUserId, String secondaryUserId, String provider)`
454472

0 commit comments

Comments
 (0)