Skip to content

Commit d069a43

Browse files
zimegClaude
andcommitted
feat(methods): add oauth.v2.user.access method example
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent 12c96ce commit d069a43

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎methods/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ $ mvn compile exec:java -Dexec.mainClass=chat.ChatPostMessage # Make the reques
7070

7171
- **[oauth.v2.beginShortTokenRotation](https://docs.slack.dev/reference/methods/oauth.v2.beginShortTokenRotation)**: Begins rotating the secret on an API token with a short secret. [Implementation](./src/main/java/oauth/v2/OAuthV2BeginShortTokenRotation.java).
7272
- **[oauth.v2.completeShortTokenRotation](https://docs.slack.dev/reference/methods/oauth.v2.completeShortTokenRotation)**: Finishes rotating the secret on an API token with a short secret. [Implementation](./src/main/java/oauth/v2/OAuthV2CompleteShortTokenRotation.java).
73+
- **[oauth.v2.user.access](https://docs.slack.dev/reference/methods/oauth.v2.user.access)**: Exchanges a temporary OAuth verifier code for a user access token. [Implementation](./src/main/java/oauth/v2/user/OAuthV2UserAccess.java).
7374

7475
### slackbot
7576

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package oauth.v2.user;
2+
3+
import com.slack.api.Slack;
4+
import com.slack.api.methods.MethodsClient;
5+
import com.slack.api.methods.SlackApiException;
6+
import com.slack.api.methods.request.oauth.OAuthV2UserAccessRequest;
7+
import com.slack.api.methods.response.oauth.OAuthV2UserAccessResponse;
8+
import java.io.IOException;
9+
10+
public class OAuthV2UserAccess {
11+
12+
public static void main(String[] args) throws IOException, SlackApiException {
13+
// Initialize
14+
MethodsClient methods = Slack.getInstance().methods();
15+
16+
// Call the oauth.v2.user.access method
17+
OAuthV2UserAccessRequest request = OAuthV2UserAccessRequest.builder()
18+
.clientId("2141029472.691202649728")
19+
.clientSecret("e1b9e11dfcd19c1982d5de12921e17e8c")
20+
.code("4724469134.4644010092847.232b4e6d82c333b475fc30f5f5a341d294feb1a94392c2fd791f7ab7731a443d1a")
21+
.build();
22+
OAuthV2UserAccessResponse response = methods.oauthV2UserAccess(request);
23+
24+
// Inspect the response
25+
System.out.println(response);
26+
}
27+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"display_information": {
3+
"name": "Slack API Methods",
4+
"description": "Example implementations to call \"oauth.v2.user\" methods"
5+
},
6+
"oauth_config": {
7+
"scopes": {
8+
"user": []
9+
}
10+
},
11+
"settings": {
12+
"org_deploy_enabled": true,
13+
"socket_mode_enabled": false,
14+
"token_rotation_enabled": false
15+
}
16+
}

0 commit comments

Comments
 (0)