com.googlecode.flickrjandroid.oauth.OAuthToken Java Examples

The following examples show how to use com.googlecode.flickrjandroid.oauth.OAuthToken. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddCommentTask.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
protected String doInBackground(OAuth... params) {
    OAuth oauth = params[0];
    if (oauth != null) {
        OAuthToken token = oauth.getToken();
        try {
            Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
                    token.getOauthToken(), token.getOauthTokenSecret());
            return f.getCommentsInterface().addComment(mPhoto.getId(),
                    mCommentText);
        } catch (Exception e) {
            e.printStackTrace();
            mException = e;
        }
    } else {
        Log.e(TAG, "AddCommentTask requires authentication");
    }
    return null;
}
 
Example #2
Source File: GetRequestToken.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
protected String doInBackground(Void... params) {
    try {
        Flickr f = FlickrHelper.getInstance().getFlickr();

        OAuthToken oauthToken = f.getOAuthInterface().getRequestToken(
                mOAuthCallbackUri.toString());
        saveRequestToken(oauthToken.getOauthTokenSecret());

        URL oauthUrl = f.getOAuthInterface().buildAuthenticationUrl(
                Permission.WRITE, oauthToken);

        return oauthUrl.toString();
    } catch (Exception e) {
        e.printStackTrace();
        mException = e;
    }
    return null;
}
 
Example #3
Source File: LoadContactsPhotosTask.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Photo> doInBackground(OAuth... params) {
    OAuth oauth = params[0];
    if (oauth != null) {
        OAuthToken token = oauth.getToken();
        Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
                token.getOauthToken(), token.getOauthTokenSecret());
        try {
            return f.getPhotosInterface().getContactsPhotos(
                    Constants.FETCH_PER_PAGE, Constants.EXTRAS,
                    false, false, false, mPage,
                    Constants.FETCH_PER_PAGE);
        } catch (Exception e) {
            e.printStackTrace();
            mException = e;
        }
    } else {
        Log.e(TAG, "LoadContactsPhotosTask requires authentication");
    }
    return null;
}
 
Example #4
Source File: LoadGroupsTask.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
protected Collection<Group> doInBackground(OAuth... params) {
    OAuth oauth = params[0];
    if (oauth != null) {
        OAuthToken token = oauth.getToken();
        Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
                token.getOauthToken(), token.getOauthTokenSecret());
        try {
            return f.getPoolsInterface().getGroups();
        } catch (Exception e) {
            e.printStackTrace();
            mException = e;
        }
    } else {
        Log.e(TAG, "LoadGroupsTask requires authentication");
    }
    return null;
}
 
Example #5
Source File: SetFavoriteTask.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
protected Exception doInBackground(OAuth... params) {
    OAuth oauth = params[0];
    if (oauth != null) {
        OAuthToken token = oauth.getToken();
        Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
                token.getOauthToken(), token.getOauthTokenSecret());
        try {
            if (mPhoto.isFavorite()) {
                f.getFavoritesInterface().remove(mPhoto.getId());
            } else {
                f.getFavoritesInterface().add(mPhoto.getId());
            }
        } catch (Exception e) {
            e.printStackTrace();
            return e;
        }
    } else {
        Log.e(TAG, "SetFavoriteTask requires authentication");
    }
    return null;
}
 
Example #6
Source File: LoadFlickrActivityTask.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
protected List<Item> doInBackground(OAuth... params) {
    OAuth oauth = params[0];
    if (oauth != null) {
        OAuthToken token = oauth.getToken();
        try {
            Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
                    token.getOauthToken(), token.getOauthTokenSecret());
            String timeFrame = "100d";
            int page = 1;
            return f.getActivityInterface().userPhotos(
                    Constants.FETCH_PER_PAGE, page, timeFrame);
        } catch (Exception e) {
            e.printStackTrace();
            mException = e;
        }
    } else {
        Log.e(TAG, "LoadFlickrActivityTask requires authentication");
    }
    return null;
}
 
Example #7
Source File: LoginFragment.java    From glimmr with Apache License 2.0 5 votes vote down vote up
private void persistAccessToken(OAuth oauth) {
    SharedPreferences sp = mActivity.getSharedPreferences(
            Constants.PREFS_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();

    OAuthToken token = oauth.getToken();
    User user = oauth.getUser();

    editor.putString(Constants.KEY_OAUTH_TOKEN, token.getOauthToken());
    editor.putString(Constants.KEY_TOKEN_SECRET, token
            .getOauthTokenSecret());
    editor.putString(Constants.KEY_ACCOUNT_USER_NAME, user.getUsername());
    editor.putString(Constants.KEY_ACCOUNT_USER_ID, user.getId());
    editor.commit();
}
 
Example #8
Source File: StackWidgetService.java    From glimmr with Apache License 2.0 5 votes vote down vote up
private List<Photo> getFavoritePhotos() throws Exception {
    OAuthToken token = mOAuth.getToken();
    Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
            token.getOauthToken(),
            token.getOauthTokenSecret());
    Date minFavDate = null;
    Date maxFavDate = null;
    return f.getFavoritesInterface().getList(mUser.getId(), minFavDate,
            maxFavDate, Constants.FETCH_PER_PAGE, PAGE, Constants.EXTRAS);
}
 
Example #9
Source File: StackWidgetService.java    From glimmr with Apache License 2.0 5 votes vote down vote up
private List<Photo> getUserPhotos() throws Exception {
    OAuthToken token = mOAuth.getToken();
    Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
            token.getOauthToken(), token.getOauthTokenSecret());
    return f.getPeopleInterface().getPhotos(mUser.getId(),
            Constants.EXTRAS, Constants.FETCH_PER_PAGE, PAGE);
}
 
Example #10
Source File: StackWidgetService.java    From glimmr with Apache License 2.0 5 votes vote down vote up
private List<Photo> getContactsPhotos() throws Exception {
    OAuthToken token = mOAuth.getToken();
    Flickr f = FlickrHelper.getInstance().getFlickrAuthed(
            token.getOauthToken(), token.getOauthTokenSecret());
    boolean justFriends = false;
    boolean singlePhoto = false;
    boolean includeSelf = false;
    return f.getPhotosInterface().getContactsPhotos(
            Constants.FETCH_PER_PAGE, Constants.EXTRAS,
            justFriends, singlePhoto, includeSelf, PAGE,
            Constants.FETCH_PER_PAGE);
}
 
Example #11
Source File: FlickrHelper.java    From glimmr with Apache License 2.0 5 votes vote down vote up
public Flickr getFlickrAuthed(String token, String secret) {
    Flickr f = getFlickr();
    RequestContext requestContext = RequestContext.getRequestContext();
    OAuth auth = new OAuth();
    auth.setToken(new OAuthToken(token, secret));
    requestContext.setOAuth(auth);
    return f;
}
 
Example #12
Source File: FlickrApi.java    From flickr-uploader with GNU General Public License v2.0 5 votes vote down vote up
private static void updateOauth() {
	String accessToken = Utils.getStringProperty(STR.accessToken);
	String accessTokenSecret = Utils.getStringProperty(STR.accessTokenSecret);
	authentified = ToolString.isNotBlank(accessToken) && ToolString.isNotBlank(accessTokenSecret);
	auth = new OAuth();
	auth.setToken(new OAuthToken(accessToken, accessTokenSecret));
}