Skip to content

Commit 00b9d73

Browse files
committed
allow perms to be specified in Flickr Api (read, write, or delete) (thanks to https://github.com/rogerhu)
1 parent d1812c4 commit 00b9d73

4 files changed

Lines changed: 15 additions & 90 deletions

File tree

changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[SNAPSHOT]
22
* omit the client_secret parameter if it is an empty string while refreshing token (thanks to https://github.com/KungfuPancake)
3+
* allow perms to be specified in Flickr Api (read, write, or delete) (thanks to https://github.com/rogerhu)
34

45
[4.1.0]
56
* make client_secret optional in OAuth2 while requesting AccessToken (if set to null, it's not required by OAuth2 specs)

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,21 @@ public class FlickrApi extends DefaultApi10a {
1212

1313
private static final String AUTHORIZE_URL = "https://www.flickr.com/services/oauth/authorize?oauth_token=%s";
1414

15-
public enum FLICKR_PERM {
15+
public enum FlickrPerm {
1616
READ, WRITE, DELETE
1717
};
1818

19-
private String permString; /* read, write, or delete (delete includes read/write) */
19+
/**
20+
* read, write, or delete (delete includes read/write)
21+
*/
22+
private final String permString;
2023

21-
public FlickrApi() {
24+
protected FlickrApi() {
2225
permString = null;
2326
}
2427

25-
public FlickrApi(FLICKR_PERM perm) {
26-
switch(perm) {
27-
case READ:
28-
this.permString = "read";
29-
break;
30-
case WRITE:
31-
this.permString = "write";
32-
break;
33-
case DELETE:
34-
this.permString = "delete";
35-
}
28+
public FlickrApi(FlickrPerm perm) {
29+
permString = perm.name().toLowerCase();
3630
}
3731

3832
private static class InstanceHolder {

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FlickrExample.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package com.github.scribejava.apis.examples;
22

3-
import java.util.Scanner;
4-
import com.github.scribejava.core.builder.ServiceBuilder;
53
import com.github.scribejava.apis.FlickrApi;
4+
import com.github.scribejava.core.builder.ServiceBuilder;
65
import com.github.scribejava.core.model.OAuth1AccessToken;
76
import com.github.scribejava.core.model.OAuth1RequestToken;
87
import com.github.scribejava.core.model.OAuthRequest;
98
import com.github.scribejava.core.model.Response;
109
import com.github.scribejava.core.model.Verb;
1110
import com.github.scribejava.core.oauth.OAuth10aService;
11+
1212
import java.io.IOException;
13+
import java.util.Scanner;
1314
import java.util.concurrent.ExecutionException;
1415

1516
public final class FlickrExample {
@@ -23,10 +24,11 @@ public static void main(String... args) throws IOException, InterruptedException
2324
// Replace these with your own api key and secret
2425
final String apiKey = "your_app_id";
2526
final String apiSecret = "your_api_secret";
27+
2628
final OAuth10aService service = new ServiceBuilder()
2729
.apiKey(apiKey)
2830
.apiSecret(apiSecret)
29-
.build(FlickrApi.instance());
31+
.build(new FlickrApi(FlickrApi.FlickrPerm.DELETE));
3032
final Scanner in = new Scanner(System.in);
3133

3234
System.out.println("=== Flickr's OAuth Workflow ===");
@@ -40,7 +42,7 @@ public static void main(String... args) throws IOException, InterruptedException
4042

4143
System.out.println("Now go and authorize ScribeJava here:");
4244
final String authorizationUrl = service.getAuthorizationUrl(requestToken);
43-
System.out.println(authorizationUrl + "&perms=read");
45+
System.out.println(authorizationUrl);
4446
System.out.println("And paste the verifier here");
4547
System.out.print(">>");
4648
final String oauthVerifier = in.nextLine();

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/FlickrExampleWithPerms.java

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)