-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDefaultApi20.java
More file actions
72 lines (64 loc) · 1.97 KB
/
DefaultApi20.java
File metadata and controls
72 lines (64 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.scribe.builder.api;
import org.scribe.http.OAuthRequestFactory;
import org.scribe.model.Encoding;
import org.scribe.model.OAuthConfig;
import org.scribe.model.Verb;
import org.scribe.oauth.OAuth20ServiceImpl;
import org.scribe.oauth.OAuthService;
import org.scribe.processors.extractors.TokenExtractor;
import org.scribe.processors.extractors.TokenExtractor20Impl;
/**
* Default implementation of the OAuth protocol, version 2.0 (draft 11)
*
* This class is meant to be extended by concrete implementations of the API,
* providing the endpoints and endpoint-http-verbs.
*
* If your Api adheres to the 2.0 (draft 11) protocol correctly, you just need to extend
* this class and define the getters for your endpoints.
*
* If your Api does something a bit different, you can override the different
* extractors or services, in order to fine-tune the process. Please read the
* javadocs of the interfaces to get an idea of what to do.
*
* @author Diego Silveira
*
*/
public abstract class DefaultApi20 implements Api {
/**
* Returns the access token extractor.
*
* @return access token extractor
*/
@Override
public TokenExtractor getAccessTokenExtractor() {
return new TokenExtractor20Impl();
}
/**
* Returns the verb for the access token endpoint (defaults to GET).
*
* @return access token endpoint verb
*/
@Override
public Verb getAccessTokenVerb() {
return Verb.GET;
}
@Override
public boolean hasGrantType() { return false; }
@Override
public String getGrantType() {
throw new UnsupportedOperationException("NOt Supported");
}
/**
* Returns the encoding for the access token request (defaults to QUERY).
*
* @return access token encoding type
*/
@Override
public Encoding getAccessTokenEncoding() { return Encoding.QUERY; }
/**
* {@inheritDoc}
*/
public OAuthService createService(final OAuthConfig config) {
return new OAuth20ServiceImpl(this, config, new OAuthRequestFactory());
}
}