Git Product home page Git Product logo

loglr's Introduction

Download Android Arsenal

Loglr

So happy to inform this library has been ported to Kotlin!

The easiest way to get your user logged in via Tumblr

Loglr is library that enables developers to implement 'Login via Tumblr' with as minimum frustration as possible.

Note : The library is in active development. On and off, one may encounter bugs or mistakes. Please report them on the issue tracker.

Download the demo application from the PlayStore!

Get it on Google Play

Importing to your project

Gradle :

    implementation 'com.daksh:loglr:2.1.4'

Usage

Loglr uses singleton pattern and accepts a minimum of 5 parameters to complete the login process. Each method that accepts a parameter returns the Loglr Instance to avoid boiler plate code. Retrieve the Loglr instance and set up the Consumer Key and Consumer Secret Key received from Tumblr apps dashboard. You get these when you set up a new app.

    Loglr.
        //Set your application consumer key from Tumblr
        .setConsumerKey("ENTER CONSUMER KEY HERE")
     
        //Set your application Secret consumer key from Tumblr
        .setConsumerSecretKey("ENTER CONSUMER SECRET KEY")

Up next, you need to pass an interface that will be called when Login succeeds.

        //Implement interface to receive Token and Secret Token
        .setLoginListener(loginListener) 

In case login fails and exceptions are thrown, an exception handler interface needs to be passed so you may ascertain reasons for failure.

        //Interface to receive call backs when things go wrong
        .setExceptionHandler(exceptionHandler)

Amongst the most important parameters, is the URL callback method. Post login, Tumblr redirects the authenticating user to the callback URL set up on Tumblr Apps dashboard. When the URL is received by Loglr, further login procedure is carried out. If no URL is provided, the login shall fail.

        //The URL callback needs to be same as the one entered on the Tumblr Apps Dashboard
        .setUrlCallBack(strUrlCallback)

Optionally, if you prefer having your own loading dialogs replaced with default ones, you may do so by passing the class that extends Dialog. This gives you an opportunity to present your users with a consistent experience with the rest of the app elements. Please note, an object of the custom dialog is manufactured by Loglr by calling the default constructor. Please ensure the class does not require any other parameters to be passed. To view an example, please refer MainActivity and LoadingDialog classes under app folder.

        //Pass the Loading Dialog class
        .setLoadingDialog(LoadingDialog.class)

Loglr supports auto detecting the OTP message received by users with 2 Factor-Authentication enabled. A dialog informing the user is displayed before the permission is requested. If you wish to disable this feature, you may do so by calling the following method and passing false. Note : by default, this feature is enabled.

        //Pass a boolean variable that informs loglr if OTP auto detection is to be enabled or not
        .enable2FA(true)

To customize the action bar background color and address bar color, you may use :

        //Pass the color resource ID
        .setActionbarColor(R.color.activity_color_actionbar)
        .setTextColor(R.color.activity_color_text)

Finally, start the login procedure.

        //Initiate login in an activity of it's own
        .initiate(context);

When login succeeds, a call back is executed to the LoginListener that was passed with .setLoginListener(loginListener) method. An object of LoginResult is passed which contains Token and Secret Token which may be used in conjunction with Jumlr Library to retrieve user information or make requests on user's behalf.

        String strOAuthToken = loginResult.getOAuthToken();
        String strOAuthTokenSecret = loginResult.getOAuthTokenSecret();

To use received tokens with Jumblr :

        // Create a new client
        JumblrClient client = new JumblrClient("ENTER CONSUMER KEY HERE", "ENTER CONSUMER SECRET KEY");
        client.setToken(strOAuthToken, strOAuthTokenSecret);

With Jumblr client set, API requests may be made. For more information on basic usage, refer Tumblr's Jumblr's official guide.

Foot notes

Permissions listed in manifest :

  • READ_SMS & RECEIVE_SMS : They are used to auto-populate OTP (2 Factor-Authentication) if the user has them enabled on Tumblr.
  • WAKE_LOCK & ACCESS_NETWORK_STATE : Firebase analytics uses these permissions to ensure events are logged properly.

If you wish to remove any permission from your app, add the following line in each of the permissions you wish to remove : tools:node="remove"

Change log

v2.1.3
  • Fixed crashes while reading OTPs;
  • Implemented the Kotlin singleton pattern;
  • Added more customization options;
v2.1.2
  • Fixed bugs with Custom dialogs;
  • Deleted deprecated files & methods;
v2.1.1
  • Library ported to Kotlin;
  • Removed silly Firebase analytics;
  • Removed Fragment implementation of the login;
  • Better activity implementation to mimic custom tabs (Tried custom tabs - but due to its limitations, its not possible to use if for OAuth);
  • Fixed a bug reported on the bug tracker;
v1.2.1
  • Developer has option to toggle auto OTP detection for 2FA;
  • Better analytics to track user/developer behavior with library;
  • Bug fix for corner case when Tumblr OAuth page fails to open;
v1.1.1
  • Custom Loading Dialogs when tokens are being exchanged and the user is required to wait;
  • Auto populate OTP if 2 Factor-Authentication is enabled by user;
  • Crash analytics so I may push out new builds if any one is experiencing crashes in their apps due Loglr;
v1.0.0
  • Changed Version to v1 post no bug being reported;
  • Marked as stable release;
v0.3.1
  • Support for initiating login process in a DialogFragment;
  • Custom URL callback;
  • Code clean up;
v0.2.2
  • Changed method names for better understanding;
v0.2.1
  • Bug Fixes;
v0.2
  • First Release;

Open Source Libraries

  • SignPost
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

License

Loglr is an open source library that enables developers to implement 'Login via Tumblr' with as minimum frustration as possible.
Copyright (C) 2016  Daksh Srivastava

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

Credits

Inspired from the work by jansanz at TumblrOAuthDemo.

loglr's People

Contributors

archern9 avatar dakshsrivastava avatar devkishore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

loglr's Issues

Logout

How to get logout after logging in ?

NullPointerException on Login

Hi,

I am facing an issue while trying to login, here is the output:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.webkit.WebSettings android.webkit.WebView.getSettings()' on a null object reference at com.tumblr.loglr.TaskTumblrLogin.onPostExecute(TaskTumblrLogin.java:203) at com.tumblr.loglr.TaskTumblrLogin.onPostExecute(TaskTumblrLogin.java:34) at android.os.AsyncTask.finish(AsyncTask.java:679) at android.os.AsyncTask.access$500(AsyncTask.java:180) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:696) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:150) at android.app.ActivityThread.main(ActivityThread.java:5621) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)

any advice on here? Thanks!

Logout Functionality

I have integrated tumblr in application , integrated Loglr, works perfect on new project, I like to do sign out functionality in application, But don't know how to do..

Tumblr Login Failed

Hello,

I am using 'com.daksh:loglr:1.2.1' dependency in my android application for tumblr login.

It works in other devices but when try to login Tumblr in "Moto g4 plus" device (Android OS 7.0) it always calls onLoginFailed listener.

Below is my stack trace:

09-07 17:53:08.124 4232-6796/com.oolotta W/DefaultRequestDirector: Authentication error: Unable to respond to any of these challenges: {oauth_consumer=WWW-Authenticate: Oauth_consumer realm="api", cookie=WWW-Authenticate: Cookie realm="web"}
09-07 17:53:08.125 4232-6796/com.oolotta W/System.err: oauth.signpost.exception.OAuthNotAuthorizedException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.
09-07 17:53:08.125 4232-6796/com.oolotta W/System.err: at oauth.signpost.AbstractOAuthProvider.handleUnexpectedResponse(AbstractOAuthProvider.java:243)
09-07 17:53:08.125 4232-6796/com.oolotta W/System.err: at oauth.signpost.AbstractOAuthProvider.retrieveToken(AbstractOAuthProvider.java:193)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at oauth.signpost.AbstractOAuthProvider.retrieveRequestToken(AbstractOAuthProvider.java:74)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at com.tumblr.loglr.TaskTumblrLogin.doInBackground(TaskTumblrLogin.java:152)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at com.tumblr.loglr.TaskTumblrLogin.doInBackground(TaskTumblrLogin.java:34)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:304)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
09-07 17:53:08.126 4232-6796/com.oolotta W/System.err: at java.lang.Thread.run(Thread.java:761)
09-07 17:53:08.134 4232-4232/com.oolotta E/FA: Name must consist of letters, digits or _ (underscores). Type, name: event, Login Failed
09-07 17:53:08.134 4232-4232/com.oolotta W/System.err: com.tumblr.loglr.Exceptions.LoglrLoginException: Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match.
09-07 17:53:08.135 4232-4232/com.oolotta W/System.err: at com.tumblr.loglr.TaskTumblrLogin.doInBackground(TaskTumblrLogin.java:162)
09-07 17:53:08.135 4232-4232/com.oolotta W/System.err: at com.tumblr.loglr.TaskTumblrLogin.doInBackground(TaskTumblrLogin.java:34)
09-07 17:53:08.135 4232-4232/com.oolotta W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:304)
09-07 17:53:08.135 4232-4232/com.oolotta W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-07 17:53:08.135 4232-4232/com.oolotta W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
09-07 17:53:08.135 4232-4232/com.oolotta W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
09-07 17:53:08.135 4232-4232/com.oolotta W/System.err: at java.lang.Thread.run(Thread.java:761)
09-07 17:53:08.139 4232-6721/com.oolotta D/FA: Logging event (FE): _err, Bundle[{_o=auto, _el=12, _ev=Login Failed, _sc=LoglrActivity, _si=4348724245434743105, _err=2}]
09-07 17:53:08.194 4232-6721/com.oolotta V/FA: Recording user engagement, ms: 1036
09-07 17:53:08.195 4232-6721/com.oolotta V/FA: Activity paused, time: 28381262
09-07 17:53:08.199 4232-6721/com.oolotta D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=1036, _sc=LoglrActivity, _si=4348724245434743105}]
09-07 17:53:08.237 4232-6721/com.oolotta V/FA: Activity resumed, time: 28381285
09-07 17:53:13.239 4232-6721/com.oolotta V/FA: Inactivity, disconnecting from the service

Please help...

Auto OTP Detection

For people using 2FA on Tumblr, support for auto detection of OTP message.

Custom Dialogs

At present, default ProgressDialogs are displayed to the user while data is loading from the server and it requires waiting. This functionality will enable the library to accept custom Dialogs from developers so that user experience may be maintained consistent throughout the application.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.