File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
examples/src/main/java/com/softlayer/api/example Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,14 @@ public void start(String[] args) throws Exception {
1717 baseUrl += '/' ;
1818 }
1919
20- run (new RestApiClient (baseUrl ).withCredentials (args [0 ], args [1 ]));
20+ RestApiClient client ;
21+ // mvn -e -q compile exec:java -Dexec.args="QuickTest Bearer eyJraWQ.....
22+ if (args [0 ].trim ().equals ("Bearer" )) {
23+ client = new RestApiClient (baseUrl ).withBearerToken (args [1 ]);
24+ } else {
25+ client = new RestApiClient (baseUrl ).withCredentials (args [0 ], args [1 ]);
26+ }
27+ run (client );
2128 }
2229
2330 /** Run the example with the given client */
Original file line number Diff line number Diff line change 1+ package com .softlayer .api .example ;
2+
3+ import com .softlayer .api .ApiClient ;
4+ import com .softlayer .api .RestApiClient ;
5+ import com .softlayer .api .service .Account ;
6+
7+
8+ /** A quick example for testing if authentication works.
9+
10+ cd softlayer-java/examples
11+ mvn -e -q compile exec:java -Dexec.args="QuickTest Bearer eyJraWQ.....
12+ */
13+ public class QuickTest extends Example {
14+
15+ @ Override
16+ public void run (ApiClient client ) throws Exception {
17+ client .withLoggingEnabled ();
18+ System .out .format ("Authorization: %s\n " , client .getCredentials ());
19+ Account .Service service = Account .service (client );
20+
21+ Account account = service .getObject ();
22+ System .out .format ("Account Name: %s\n " , account .getCompanyName ());
23+ }
24+
25+ public static void main (String [] args ) throws Exception {
26+ new QuickTest ().start (args );
27+ }
28+ }
You can’t perform that action at this time.
0 commit comments