Skip to content

Commit 784bb6e

Browse files
committed
state param should be used only for authorization url generation, for v2 only, for Authorization Code Grant only, and it should be set per request, not per created OAuthService
1 parent 872af9a commit 784bb6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+388
-71
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ ScribeJava support out-of-box several HTTP clients:
4242

4343
### Supports many flows and additional features
4444

45-
* [RFC 6749](https://tools.ietf.org/html/rfc6749) The OAuth 2.0 Authorization Framework, [Authorization Code Authorization Grant](https://tools.ietf.org/html/rfc6749#section-4.1) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20Example.java)
46-
* [RFC 6749](https://tools.ietf.org/html/rfc6749) The OAuth 2.0 Authorization Framework, [Client Credentials Authorization Grant](https://tools.ietf.org/html/rfc6749#section-4.4) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java)
45+
* [RFC 6749](https://tools.ietf.org/html/rfc6749) The OAuth 2.0 Authorization Framework, [Authorization Code Authorization Grant](https://tools.ietf.org/html/rfc6749#section-4.1), [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20Example.java)
4746
* [RFC 6749](https://tools.ietf.org/html/rfc6749) The OAuth 2.0 Authorization Framework, [Resource Owner Password Credentials Authorization Grant](https://tools.ietf.org/html/rfc6749#section-4.3)
48-
* [RFC 6749](https://tools.ietf.org/html/rfc6749) The OAuth 2.0 Authorization Framework, [Refreshing an Access Token](https://tools.ietf.org/html/rfc6749#section-6) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20Example.java#L77)
47+
* [RFC 6749](https://tools.ietf.org/html/rfc6749) The OAuth 2.0 Authorization Framework, [Client Credentials Authorization Grant](https://tools.ietf.org/html/rfc6749#section-4.4), [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/VkontakteClientCredentialsGrantExample.java)
48+
* [RFC 6749](https://tools.ietf.org/html/rfc6749) The OAuth 2.0 Authorization Framework, [Refreshing an Access Token](https://tools.ietf.org/html/rfc6749#section-6), [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20Example.java#L77)
4949
* [RFC 6750](https://tools.ietf.org/html/rfc6750) The OAuth 2.0 Authorization Framework: Bearer Token Usage
50-
* [RFC 7636](https://tools.ietf.org/html/rfc7636) Proof Key for Code Exchange by OAuth Public Clients (PKCE) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20WithPKCEExample.java)
51-
* [RFC 7009](https://tools.ietf.org/html/rfc7009) OAuth 2.0 Token Revocation [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20RevokeExample.java)
50+
* [RFC 7636](https://tools.ietf.org/html/rfc7636) Proof Key for Code Exchange by OAuth Public Clients (PKCE), [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20WithPKCEExample.java)
51+
* [RFC 7009](https://tools.ietf.org/html/rfc7009) OAuth 2.0 Token Revocation, [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Google20RevokeExample.java)
5252

5353
### Supports all major 1.0a and 2.0 OAuth APIs out-of-the-box
5454

changelog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* remove any Google+ mention (switch to clean Google OAuth2) (thanks to https://github.com/fvasco)
44
* fix Microsoft Azure AD v1.0 and v2.0 (thanks to https://github.com/kenpusney and https://github.com/oscararias)
55
* add new API Asana (https://asana.com/) (thanks to https://github.com/joestazak)
6+
* state param should be used only for authorization url generation, for v2 only, for Authorization Code Grant only,
7+
and it should be set per request, not per created OAuthService
68

79
[6.2.0]
810
* add new API Microsoft Azure Active Directory (Azure AD) 2.0 (thanks to https://github.com/rzukow and https://github.com/dgrudenic)

scribejava-apis/src/main/java/com/github/scribejava/apis/FacebookApi.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,34 @@ public ClientAuthentication getClientAuthentication() {
7070
return RequestBodyAuthenticationScheme.instance();
7171
}
7272

73+
/**
74+
* @param apiKey apiKey
75+
* @param apiSecret apiSecret
76+
* @param callback callback
77+
* @param scope scope
78+
* @param debugStream debugStream
79+
* @param state state
80+
* @param responseType responseType
81+
* @param userAgent userAgent
82+
* @param httpClientConfig httpClientConfig
83+
* @param httpClient httpClient
84+
* @return return
85+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
86+
*/
87+
@Deprecated
7388
@Override
7489
public FacebookService createService(String apiKey, String apiSecret, String callback, String scope,
7590
OutputStream debugStream, String state, String responseType, String userAgent,
7691
HttpClientConfig httpClientConfig, HttpClient httpClient) {
7792
return new FacebookService(this, apiKey, apiSecret, callback, scope, state, responseType, userAgent,
7893
httpClientConfig, httpClient);
7994
}
95+
96+
@Override
97+
public FacebookService createService(String apiKey, String apiSecret, String callback, String scope,
98+
OutputStream debugStream, String responseType, String userAgent, HttpClientConfig httpClientConfig,
99+
HttpClient httpClient) {
100+
return createService(apiKey, apiSecret, callback, scope, debugStream, null, responseType, userAgent,
101+
httpClientConfig, httpClient);
102+
}
80103
}

scribejava-apis/src/main/java/com/github/scribejava/apis/ImgurApi.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ protected String getAuthorizationBaseUrl() {
5454
throw new UnsupportedOperationException("use getAuthorizationUrl instead");
5555
}
5656

57+
/**
58+
* @param apiKey apiKey
59+
* @param apiSecret apiSecret
60+
* @param callback callback
61+
* @param scope scope
62+
* @param debugStream debugStream
63+
* @param state state
64+
* @param responseType responseType
65+
* @param userAgent userAgent
66+
* @param httpClientConfig httpClientConfig
67+
* @param httpClient httpClient
68+
* @return return
69+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
70+
*/
71+
@Deprecated
5772
@Override
5873
public ImgurOAuthService createService(String apiKey, String apiSecret, String callback, String scope,
5974
OutputStream debugStream, String state, String responseType, String userAgent,
@@ -62,6 +77,14 @@ public ImgurOAuthService createService(String apiKey, String apiSecret, String c
6277
httpClientConfig, httpClient);
6378
}
6479

80+
@Override
81+
public ImgurOAuthService createService(String apiKey, String apiSecret, String callback, String scope,
82+
OutputStream debugStream, String responseType, String userAgent, HttpClientConfig httpClientConfig,
83+
HttpClient httpClient) {
84+
return createService(apiKey, apiSecret, callback, scope, debugStream, null, responseType, userAgent,
85+
httpClientConfig, httpClient);
86+
}
87+
6588
public static boolean isOob(String callback) {
6689
return OAuthConstants.OOB.equals(callback);
6790
}

scribejava-apis/src/main/java/com/github/scribejava/apis/MailruApi.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,34 @@ protected String getAuthorizationBaseUrl() {
2929
return "https://connect.mail.ru/oauth/authorize";
3030
}
3131

32+
/**
33+
* @param apiKey apiKey
34+
* @param apiSecret apiSecret
35+
* @param callback callback
36+
* @param scope scope
37+
* @param debugStream debugStream
38+
* @param state state
39+
* @param responseType responseType
40+
* @param userAgent userAgent
41+
* @param httpClientConfig httpClientConfig
42+
* @param httpClient httpClient
43+
* @return return
44+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
45+
*/
46+
@Deprecated
3247
@Override
3348
public MailruOAuthService createService(String apiKey, String apiSecret, String callback, String scope,
3449
OutputStream debugStream, String state, String responseType, String userAgent,
3550
HttpClientConfig httpClientConfig, HttpClient httpClient) {
3651
return new MailruOAuthService(this, apiKey, apiSecret, callback, scope, state, responseType, userAgent,
3752
httpClientConfig, httpClient);
3853
}
54+
55+
@Override
56+
public MailruOAuthService createService(String apiKey, String apiSecret, String callback, String scope,
57+
OutputStream debugStream, String responseType, String userAgent, HttpClientConfig httpClientConfig,
58+
HttpClient httpClient) {
59+
return createService(apiKey, apiSecret, callback, scope, debugStream, null, responseType, userAgent,
60+
httpClientConfig, httpClient);
61+
}
3962
}

scribejava-apis/src/main/java/com/github/scribejava/apis/OdnoklassnikiApi.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,21 @@ protected String getAuthorizationBaseUrl() {
3333
return "https://connect.ok.ru/oauth/authorize";
3434
}
3535

36+
/**
37+
* @param apiKey apiKey
38+
* @param apiSecret apiSecret
39+
* @param callback callback
40+
* @param scope scope
41+
* @param debugStream debugStream
42+
* @param state state
43+
* @param responseType responseType
44+
* @param userAgent userAgent
45+
* @param httpClientConfig httpClientConfig
46+
* @param httpClient httpClient
47+
* @return return
48+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
49+
*/
50+
@Deprecated
3651
@Override
3752
public OdnoklassnikiOAuthService createService(String apiKey, String apiSecret, String callback, String scope,
3853
OutputStream debugStream, String state, String responseType, String userAgent,
@@ -41,6 +56,14 @@ public OdnoklassnikiOAuthService createService(String apiKey, String apiSecret,
4156
httpClientConfig, httpClient);
4257
}
4358

59+
@Override
60+
public OdnoklassnikiOAuthService createService(String apiKey, String apiSecret, String callback, String scope,
61+
OutputStream debugStream, String responseType, String userAgent, HttpClientConfig httpClientConfig,
62+
HttpClient httpClient) {
63+
return createService(apiKey, apiSecret, callback, scope, debugStream, null, responseType, userAgent,
64+
httpClientConfig, httpClient);
65+
}
66+
4467
@Override
4568
public BearerSignature getBearerSignature() {
4669
return BearerSignatureURIQueryParameter.instance();

scribejava-apis/src/main/java/com/github/scribejava/apis/WunderlistAPI.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,29 @@ public ClientAuthentication getClientAuthentication() {
4848
return RequestBodyAuthenticationScheme.instance();
4949
}
5050

51+
@Override
52+
public OAuth20Service createService(String apiKey, String apiSecret, String callback, String scope,
53+
OutputStream debugStream, String responseType, String userAgent, HttpClientConfig httpClientConfig,
54+
HttpClient httpClient) {
55+
return createService(apiKey, apiSecret, callback, scope, debugStream, null, responseType, userAgent,
56+
httpClientConfig, httpClient);
57+
}
58+
59+
/**
60+
* @param apiKey apiKey
61+
* @param apiSecret apiSecret
62+
* @param callback callback
63+
* @param scope scope
64+
* @param debugStream debugStream
65+
* @param state state
66+
* @param responseType responseType
67+
* @param userAgent userAgent
68+
* @param httpClientConfig httpClientConfig
69+
* @param httpClient httpClient
70+
* @return return
71+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
72+
*/
73+
@Deprecated
5174
@Override
5275
public OAuth20Service createService(String apiKey, String apiSecret, String callback, String scope,
5376
OutputStream debugStream, String state, String responseType, String userAgent,

scribejava-apis/src/main/java/com/github/scribejava/apis/facebook/FacebookService.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,31 @@
1313

1414
public class FacebookService extends OAuth20Service {
1515

16+
/**
17+
* @param api api
18+
* @param apiKey apiKey
19+
* @param apiSecret apiSecret
20+
* @param callback callback
21+
* @param scope scope
22+
* @param state state
23+
* @param responseType responseType
24+
* @param userAgent userAgent
25+
* @param httpClientConfig httpClientConfig
26+
* @param httpClient httpClient
27+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
28+
*/
29+
@Deprecated
1630
public FacebookService(DefaultApi20 api, String apiKey, String apiSecret, String callback, String scope,
1731
String state, String responseType, String userAgent, HttpClientConfig httpClientConfig,
1832
HttpClient httpClient) {
1933
super(api, apiKey, apiSecret, callback, scope, state, responseType, userAgent, httpClientConfig, httpClient);
2034
}
2135

36+
public FacebookService(DefaultApi20 api, String apiKey, String apiSecret, String callback, String scope,
37+
String responseType, String userAgent, HttpClientConfig httpClientConfig, HttpClient httpClient) {
38+
super(api, apiKey, apiSecret, callback, scope, responseType, userAgent, httpClientConfig, httpClient);
39+
}
40+
2241
@Override
2342
public void signRequest(String accessToken, OAuthRequest request) {
2443
super.signRequest(accessToken, request);

scribejava-apis/src/main/java/com/github/scribejava/apis/imgur/ImgurOAuthService.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,31 @@
1010

1111
public class ImgurOAuthService extends OAuth20Service {
1212

13+
/**
14+
* @param api api
15+
* @param apiKey apiKey
16+
* @param apiSecret apiSecret
17+
* @param callback callback
18+
* @param scope scope
19+
* @param state state
20+
* @param responseType responseType
21+
* @param userAgent userAgent
22+
* @param httpClientConfig httpClientConfig
23+
* @param httpClient httpClient
24+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
25+
*/
26+
@Deprecated
1327
public ImgurOAuthService(DefaultApi20 api, String apiKey, String apiSecret, String callback, String scope,
1428
String state, String responseType, String userAgent, HttpClientConfig httpClientConfig,
1529
HttpClient httpClient) {
1630
super(api, apiKey, apiSecret, callback, scope, state, responseType, userAgent, httpClientConfig, httpClient);
1731
}
1832

33+
public ImgurOAuthService(DefaultApi20 api, String apiKey, String apiSecret, String callback, String scope,
34+
String responseType, String userAgent, HttpClientConfig httpClientConfig, HttpClient httpClient) {
35+
super(api, apiKey, apiSecret, callback, scope, responseType, userAgent, httpClientConfig, httpClient);
36+
}
37+
1938
@Override
2039
protected OAuthRequest createAccessTokenRequest(String oauthVerifier) {
2140
final DefaultApi20 api = getApi();

scribejava-apis/src/main/java/com/github/scribejava/apis/mailru/MailruOAuthService.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,31 @@
1616

1717
public class MailruOAuthService extends OAuth20Service {
1818

19+
/**
20+
* @param api api
21+
* @param apiKey apiKey
22+
* @param apiSecret apiSecret
23+
* @param callback callback
24+
* @param scope scope
25+
* @param state state
26+
* @param responseType responseType
27+
* @param userAgent userAgent
28+
* @param httpClientConfig httpClientConfig
29+
* @param httpClient httpClient
30+
* @deprecated use one of getAuthorizationUrl method in {@link com.github.scribejava.core.oauth.OAuth20Service}
31+
*/
32+
@Deprecated
1933
public MailruOAuthService(DefaultApi20 api, String apiKey, String apiSecret, String callback, String scope,
2034
String state, String responseType, String userAgent, HttpClientConfig httpClientConfig,
2135
HttpClient httpClient) {
2236
super(api, apiKey, apiSecret, callback, scope, state, responseType, userAgent, httpClientConfig, httpClient);
2337
}
2438

39+
public MailruOAuthService(DefaultApi20 api, String apiKey, String apiSecret, String callback, String scope,
40+
String responseType, String userAgent, HttpClientConfig httpClientConfig, HttpClient httpClient) {
41+
super(api, apiKey, apiSecret, callback, scope, responseType, userAgent, httpClientConfig, httpClient);
42+
}
43+
2544

2645
@Override
2746
public void signRequest(String accessToken, OAuthRequest request) {

0 commit comments

Comments
 (0)