Skip to content

Commit

Permalink
Enable hierarchical access to defined scopes
Browse files Browse the repository at this point in the history
- replace Name enum with hierarchical structure for a more intuitive access to individual scopes
- changing samples and USAGE.md to match

Examples:
- Scope(Scope.Name.READ) becomes Scope(Scope.READ.ALL)
- Scope(Scope.Name.ADMIN_READ_ACCOUNTS) becomes Scope(Scope.ADMIN.READ.ACCOUNTS)
  • Loading branch information
bocops committed Dec 12, 2023
1 parent a1a7d0e commit 82166ce
Show file tree
Hide file tree
Showing 10 changed files with 332 additions and 156 deletions.
8 changes: 4 additions & 4 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Additionally, this guide uses the following values that should be replaced in yo
// The actual value used instead should be a URL that will be interpreted by your application.
redirectUris = "urn:ietf:wg:oauth:2.0:oob"

// This is equal to the full range of scopes currently supported by BigBone.
// This is equal to the full range of non-admin scopes currently supported by BigBone.
// Instead of this, you should request as little as possible for your application.
scope = Scope()
fullScope = Scope(Scope.READ.ALL, Scope.WRITE.ALL, Scope.PUSH.ALL)
```

## Registering an App
Expand All @@ -46,7 +46,7 @@ val client: MastodonClient = MastodonClient.Builder(instanceHostname).build()
val appRegistration = client.apps.createApp(
clientName = "bigbone-sample-app",
redirectUris = "urn:ietf:wg:oauth:2.0:oob",
scope = Scope(),
scope = fullScope,
website = "https://example.org/"
).execute()
```
Expand All @@ -64,7 +64,7 @@ try {
AppRegistration appRegistration=client.apps().createApp(
"bigbone-sample-app",
"urn:ietf:wg:oauth:2.0:oob",
new Scope(),
fullScope,
"https://example.org/"
).execute();
} catch (BigBoneRequestException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class TestConstants {
const val USER2_EMAIL = "[email protected]"
const val USER2_PASSWORD = "user2abcdef"

/**
* This scope should allow accessing all non-admin endpoints in integration tests.
*/
val fullScope = Scope(Scope.Name.READ, Scope.Name.WRITE, Scope.Name.PUSH)
val fullScope = Scope(Scope.READ.ALL, Scope.WRITE.ALL, Scope.PUSH.ALL)
}
}
Loading

0 comments on commit 82166ce

Please sign in to comment.