-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented /api/v2/grants endpoint of auth0 management api
- Loading branch information
Showing
6 changed files
with
662 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,123 +1,126 @@ | ||
|
||
# Created by https://www.gitignore.io/api/java,gradle,osx,windows,intellij+iml | ||
|
||
### OSX ### | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
# Thumbnails | ||
._* | ||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
|
||
### Windows ### | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
|
||
### Java ### | ||
*.class | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
|
||
### Gradle ### | ||
.gradle | ||
/build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
|
||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 | ||
# gradle/wrapper/gradle-wrapper.properties | ||
|
||
# End of https://www.gitignore.io/api/java,gradle,osx,windows | ||
|
||
|
||
### Intellij+iml ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff: | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
|
||
# Sensitive or high-churn files: | ||
.idea/dataSources/ | ||
.idea/dataSources.ids | ||
.idea/dataSources.xml | ||
.idea/dataSources.local.xml | ||
.idea/sqlDataSources.xml | ||
.idea/dynamic.xml | ||
.idea/uiDesigner.xml | ||
|
||
# Gradle: | ||
.idea/gradle.xml | ||
.idea/libraries | ||
|
||
# Mongo Explorer plugin: | ||
.idea/mongoSettings.xml | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
### Intellij+iml Patch ### | ||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 | ||
|
||
*.iml | ||
modules.xml | ||
.idea/misc.xml | ||
*.ipr | ||
|
||
# End of https://www.gitignore.io/api/intellij+iml | ||
|
||
# Created by https://www.gitignore.io/api/java,gradle,osx,windows,intellij+iml | ||
|
||
### OSX ### | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
# Thumbnails | ||
._* | ||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
|
||
### Windows ### | ||
# Windows thumbnail cache files | ||
Thumbs.db | ||
ehthumbs.db | ||
ehthumbs_vista.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
|
||
### Java ### | ||
*.class | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
|
||
### Gradle ### | ||
.gradle | ||
/build/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) | ||
!gradle-wrapper.jar | ||
|
||
# Cache of project | ||
.gradletasknamecache | ||
|
||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 | ||
# gradle/wrapper/gradle-wrapper.properties | ||
|
||
# End of https://www.gitignore.io/api/java,gradle,osx,windows | ||
|
||
|
||
### Intellij+iml ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff: | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
|
||
# Sensitive or high-churn files: | ||
.idea/dataSources/ | ||
.idea/dataSources.ids | ||
.idea/dataSources.xml | ||
.idea/dataSources.local.xml | ||
.idea/sqlDataSources.xml | ||
.idea/dynamic.xml | ||
.idea/uiDesigner.xml | ||
|
||
# Gradle: | ||
.idea/gradle.xml | ||
.idea/libraries | ||
|
||
# Mongo Explorer plugin: | ||
.idea/mongoSettings.xml | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
### Intellij+iml Patch ### | ||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 | ||
|
||
*.iml | ||
modules.xml | ||
.idea/misc.xml | ||
*.ipr | ||
|
||
# End of https://www.gitignore.io/api/intellij+iml | ||
|
||
# NetBeans IDE files | ||
/.nb-gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.auth0.client.mgmt; | ||
|
||
import com.auth0.net.CustomRequest; | ||
import com.auth0.net.Request; | ||
import com.auth0.net.VoidRequest; | ||
import com.auth0.utils.Asserts; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
|
||
import okhttp3.HttpUrl; | ||
import okhttp3.OkHttpClient; | ||
|
||
import java.util.List; | ||
|
||
import com.auth0.json.mgmt.Grant; | ||
|
||
/** | ||
* Class that provides an implementation of the Grants methods of the Management API as defined in https://auth0.com/docs/api/management/v2#!/Grants/ | ||
*/ | ||
@SuppressWarnings("WeakerAccess") | ||
public class GrantsEntity extends BaseManagementEntity { | ||
|
||
GrantsEntity(OkHttpClient client, HttpUrl baseUrl, String apiToken) { | ||
super(client, baseUrl, apiToken); | ||
} | ||
|
||
/** | ||
* Request all the Client Grants. A token with scope read:client_grants is needed. | ||
* See https://auth0.com/docs/api/management/v2#!/Grants/get_grants | ||
* | ||
* @param userId The user id of the grants to retrieve | ||
* @return a Request to execute. | ||
*/ | ||
public Request<List<Grant>> list(String userId) { | ||
Asserts.assertNotNull(userId, "user id"); | ||
|
||
String url = baseUrl | ||
.newBuilder() | ||
.addPathSegments("api/v2/grants") | ||
.addQueryParameter("user_id", userId) | ||
.build() | ||
.toString(); | ||
CustomRequest<List<Grant>> request = new CustomRequest<>(client, url, "GET", new TypeReference<List<Grant>>() { | ||
}); | ||
request.addHeader("Authorization", "Bearer " + apiToken); | ||
return request; | ||
} | ||
|
||
/** | ||
* Delete an existing Grant. A token with scope delete:client_grants is needed. | ||
* See https://auth0.com/docs/api/management/v2#!/Grants/delete_grants_by_id | ||
* | ||
* @param grantId The id of the grant to delete. | ||
* @param userId The user id of the grants to delete. | ||
* @return a Request to execute. | ||
*/ | ||
public Request delete(String grantId, String userId) { | ||
Asserts.assertNotNull(grantId, "grant id"); | ||
Asserts.assertNotNull(userId, "user id"); | ||
|
||
String url = baseUrl | ||
.newBuilder() | ||
.addPathSegments("api/v2/grants") | ||
.addPathSegment(grantId) | ||
.addQueryParameter("user_id", userId) | ||
.build() | ||
.toString(); | ||
VoidRequest request = new VoidRequest(client, url, "DELETE"); | ||
request.addHeader("Authorization", "Bearer " + apiToken); | ||
return request; | ||
} | ||
|
||
} |
Oops, something went wrong.