Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcbcca1

Browse files
committed
1 parente1f9be5 commitbcbcca1

File tree

6 files changed

+17
-14
lines changed

6 files changed

+17
-14
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ ScribeJava support out-of-box several HTTP clients:
9797
* Salesforce (https://www.salesforce.com/)[example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/SalesforceExample.java),[example with Async Ning HTTP Client](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/SalesforceNingAsyncExample.java)
9898
* Sina (http://www.sina.com.cn/http://weibo.com/login.php)[example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/SinaWeibo2Example.java),[example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/SinaWeiboExample.java)
9999
* Skyrock (http://skyrock.com/)[example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/SkyrockExample.java)
100+
* Slack (https://slack.com/)[example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/SlackExample.java)
100101
* StackExchange (http://stackexchange.com/)[example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/StackExchangeExample.java)
101102
* The Things Network (v1-staging and v2-preview) (https://www.thethingsnetwork.org/)[example v1](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/TheThingsNetworkV1StagingExample.java),[example v2 preview](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/TheThingsNetworkV2PreviewExample.java)
102103
* Trello (https://trello.com/)[example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/TrelloExample.java)

‎changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[SNAPSHOT]
22
* add raw Response (with HTTP repsponse code and body) as member to the OAuth2AccessTokenErrorResponse
33
* add possibility to set "" (empty string) as apiSecret
4+
* add Slack API (https://slack.com/) (thanks to https://github.com/petrkopotev)
45

56
[8.0.0]
67
* add Kakao API (https://kakao.com/) (thanks to https://github.com/v0o0v)

‎scribejava-apis/src/main/java/com/github/scribejava/apis/SlackApi.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
packagecom.github.scribejava.apis;
22

3-
importcom.github.scribejava.apis.fitbit.FitBitJsonTokenExtractor;
43
importcom.github.scribejava.apis.slack.SlackJsonTokenExtractor;
5-
importcom.github.scribejava.apis.slack.SlackOAuth2AccessToken;
64
importcom.github.scribejava.core.builder.api.DefaultApi20;
75

86
/**
9-
* Slack.comapi
7+
* Slack.comAPI
108
*/
119
publicclassSlackApiextendsDefaultApi20 {
1210

‎scribejava-apis/src/main/java/com/github/scribejava/apis/slack/SlackJsonTokenExtractor.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ public static SlackJsonTokenExtractor instance() {
1919

2020
@Override
2121
protectedSlackOAuth2AccessTokencreateToken(StringaccessToken,StringtokenType,IntegerexpiresIn,
22-
StringrefreshToken,Stringscope,JsonNoderesponse,StringrawResponse) {
23-
StringuserAccessToken ="";
22+
StringrefreshToken,Stringscope,JsonNoderesponse,StringrawResponse) {
23+
finalStringuserAccessToken;
2424
finalJsonNodeuserAccessTokenNode =response.get("authed_user").get("access_token");
25-
if (userAccessTokenNode !=null) {
26-
userAccessToken =userAccessTokenNode.asText();
25+
if (userAccessTokenNode ==null) {
26+
userAccessToken ="";
27+
}else {
28+
userAccessToken =userAccessTokenNode.asText();
2729
}
2830

29-
returnnewSlackOAuth2AccessToken(accessToken,tokenType,expiresIn,refreshToken,scope,
30-
userAccessToken,rawResponse);
31+
returnnewSlackOAuth2AccessToken(accessToken,tokenType,expiresIn,refreshToken,scope,userAccessToken,
32+
rawResponse);
3133
}
3234
}

‎scribejava-apis/src/main/java/com/github/scribejava/apis/slack/SlackOAuth2AccessToken.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
publicclassSlackOAuth2AccessTokenextendsOAuth2AccessToken {
88

9+
privatestaticfinallongserialVersionUID =1L;
10+
911
privatefinalStringuserAccessToken;
1012

11-
publicSlackOAuth2AccessToken(StringaccessToken,StringtokenType,IntegerexpiresIn,StringrefreshToken,Stringscope,StringuserAccessToken,StringrawResponse) {
13+
publicSlackOAuth2AccessToken(StringaccessToken,StringtokenType,IntegerexpiresIn,StringrefreshToken,
14+
Stringscope,StringuserAccessToken,StringrawResponse) {
1215
super(accessToken,tokenType,expiresIn,refreshToken,scope,rawResponse);
1316
this.userAccessToken =userAccessToken;
1417
}
@@ -41,5 +44,4 @@ public boolean equals(Object obj) {
4144

4245
returnObjects.equals(userAccessToken, ((SlackOAuth2AccessToken)obj).getUserAccessToken());
4346
}
44-
4547
}

‎scribejava-apis/src/test/java/com/github/scribejava/apis/examples/SlackExample.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class SlackExample {
1919

2020
privatestaticfinalStringNETWORK_NAME ="Slack.com";
2121
privatestaticfinalStringBOT_RESOURCE_URL ="https://slack.com/api/channels.list";
22-
privatestaticfinalStringBOT_SCOPE ="channels:read"
22+
privatestaticfinalStringBOT_SCOPE ="channels:read";
2323
privatestaticfinalStringUSER_RESOURCE_URL ="https://slack.com/api/users.list";
2424
privatestaticfinalStringUSER_SCOPE ="users:read";
2525
privatestaticfinalStringPAYLOAD ="null";
@@ -86,7 +86,7 @@ public static void main(String... args) throws IOException, InterruptedException
8686
finalOAuthRequestuserRequest =newOAuthRequest(Verb.GET,USER_RESOURCE_URL);
8787
userRequest.addHeader(CONTENT_TYPE_NAME,CONTENT_TYPE_VALUE);
8888
userRequest.setPayload(PAYLOAD);
89-
SlackOAuth2AccessTokentoken = (SlackOAuth2AccessToken)accessToken;
89+
finalSlackOAuth2AccessTokentoken = (SlackOAuth2AccessToken)accessToken;
9090
service.signRequest(token.getUserAccessToken(),userRequest);
9191

9292
try (Responseresponse =service.execute(userRequest)) {
@@ -96,7 +96,6 @@ public static void main(String... args) throws IOException, InterruptedException
9696
System.out.println(response.getBody());
9797
}
9898

99-
10099
System.out.println();
101100
System.out.println("Thats it man! Go and build something awesome with ScribeJava! :)");
102101
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp