Giter Club home page Giter Club logo

asne's Introduction

Unfreeze project - merge all puls for master branch - current version was not tested - NOT STABLE

Sorry, but I freeze work on project for some time(I hope not long, nearly month) - too busy. I saw all Issues and will resolve them as soon as I can.

I checked project - current maven libs mostly works fine. For now I need help with Issues and open for pull requests - will check them and merge on weekends.

enter image description here

ASNE ASNE Maven Central Android Arsenal

ASNE library created for simple integration of social setworks to android applications. If you want to integrate your application with multiple social networks just choose ASNE modules and add them to your project. You just need to: add module, build SocialNetworkManager and configure your AndroidManiferst. ASNE contains common interface for most popular social networks, but you can easily make module for another.

ASNE contains modules for social networks:

  • Twitter
  • LinkedIn
  • Facebook
  • Google Plus
  • Instagram
  • Vkontakte
  • Odnoklassniki

Table of contents

Features
Documentation
Demo app
Getting started
Important
Developed By
License

Features

ASNE got almost all necessary requests to social networks

  • Login
  • Configure necessary permissions
  • Get Access Token
  • Get current person social profile
  • Get social profile of user by id
  • Get social profile for array of users
  • Get detailed user profile
  • Share message
  • Share photo
  • Share link
  • Request Share dialog with message/photo/link
  • Check is user(by id) is friend of current
  • Get list of Friends
  • Adding friends by id
  • Remove friend from friend list
  • Any request to chosen social network - you got full SDK/API

enter image description here

Documentation

Javadoc

Tutorial project on GitHub

Tutorial article on CodeProject

Demo app

Link for releases

Get it on Google Play

Getting started

Adding library

1) Using Maven Central

Add dependency for chosen module, here example for all modules, you can choose one or two

dependencies {
...
    compile 'com.github.asne:asne-facebook:0.3.3'
    compile 'com.github.asne:asne-twitter:0.3.3'
    compile 'com.github.asne:asne-googleplus:0.3.3'
    compile 'com.github.asne:asne-linkedin:0.3.3'
    compile 'com.github.asne:asne-instagram:0.3.3'
    compile 'com.github.asne:asne-vk:0.3.3'
    compile 'com.github.asne:asne-odnoklassniki:0.3.3'
...
}

2) Import module to your project

For example, in AndroidStudio you can add modules via Gradle:

  1. Copy social module to your project.
  2. In settings.gradle include ':ASNECore', ':socialNetworkModuleName'
  3. In build.gradle of your app (YOUR_PROJECT/app/build.gradle) add new dependencies: compile project(':socialNetworkModuleName')

Without Gradle, add ASNE like:

  1. Open Project Settings and choose Modules.
  2. Find button "Add" (+), and choose Import module
  3. Find ASNECore and socialNetworkModuleName directories - «Add».
  4. Choose Create module from existing sources, then click "Next" rename module from "main" to "ASNECore".
  5. Add new asne-module in dependencies to your app.

Using library

Firstly, you need to create app in social network. You can read about main steps:

Second, we need to catch response after login via social network login dialog:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Fragment fragment = getSupportFragmentManager().findFragmentByTag(BaseDemoFragment.SOCIAL_NETWORK_TAG);
    if (fragment != null) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    }

Then, you need to initialize mSocialNetworkManager, it contain common interface for all ASNE social network modules. Initialize chosen social network and add social network to SocialNetworkManager(example: FacebookSocialNetwork):

mSocialNetworkManager = (SocialNetworkManager) getFragmentManager().findFragmentByTag(SOCIAL_NETWORK_TAG);
	if (mSocialNetworkManager == null) {
        mSocialNetworkManager = new SocialNetworkManager();
		FacebookSocialNetwork fbNetwork = new FacebookSocialNetwork(this, fbScope);
		//or from an activity
		//FacebookSocialNetwork fbNetwork = new FacebookSocialNetwork(mSocialNetworkManager, this, fbScope);
        mSocialNetworkManager.addSocialNetwork(fbNetwork);
        getFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_NETWORK_TAG).commit();
	}

where fbScope is permissions for your app, for example I used:

ArrayList<String> fbScope = new ArrayList<String>();
fbScope.addAll(Arrays.asList("public_profile, email, user_friends, user_location, user_birthday"));

Then you can send requests to social network like:

   mSocialNetworkManager.getVKSocialNetwork().requestLogin(new OnLoginCompleteListener() {
       @Override
       public void onLoginSuccess(int socialNetworkID) {

       }

       @Override
       public void onError(int socialNetworkID, String requestID, String errorMessage, Object data) {

       }
   });

Or get Social network directly like:

	Session session = Session.getActiveSession();

Important

Facebook Upgrades

Facebook some permissions you can get only after Facebook submission, so my demo app wasn't submitted due low functionality. So if you want to use it with all functionality send me your facebook id and I add you as tester - this is easy way to to fully use demo app email: [email protected]

Apps are no longer able to retrieve the full list of a user's friends (only those friends who have specifically authorized your app using the user_friends permission) but if you add me as friend you will see me in friendlist(profile)

Developed By

ASNE developed on the basis of (Android Social Networks) mostly redone and add new features(some features are pulled to Android Social Networks)

Evgeny Gorbin - [email protected]

Follow me on Google+ Follow me on Twitter License ===================== ASNE is made available under the MIT license: [MIT license](http://opensource.org/licenses/MIT):
The MIT License (MIT)

Copyright (c) 2014 Evgrny Gorbin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

asne's People

Contributors

argusoguedes avatar fcostazini avatar gorbin avatar hibbem avatar lordofprograms avatar pnemonic78 avatar samerzmd avatar sergpalm avatar sough avatar thedumbtechguy avatar usmanrana07 avatar

Stargazers

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

Watchers

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

asne's Issues

How to get access token for google plus?

After client logins in my app, my server creates new user, based on user_id, but I must check if this authorisation is valid. To do that I send access tokens after login to my server, server check validity, but access token from google plus is empty, why is so?

twitter not working

Error:A problem occurred configuring project ':app'.

Could not resolve all dependencies for configuration ':app:_devProductionDebugCompile'.
Could not find com.github.asne:ASNECore:0.2.1.
Required by:
evenVoice:app:unspecified > com.github.asne:asne-twitter:0.2.1

GooglePlusSocialNetwork java.lang.NoSuchMethodError on init

On add to manager GooglePlusSocialNetwork (after init) fatal exception

E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoSuchMethodError: com.google.android.gms.common.api.GoogleApiClient$Builder.addApi at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.onCreate(GooglePlusSocialNetwork.java:546) at com.github.gorbin.asne.core.SocialNetworkManager.onCreate(SocialNetworkManager.java:56)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:913)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
at android.app.Activity.performStart(Activity.java:5143)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)

Odnoklassniki security error

from @basnopisets,

Еще один момент - при логине в логи выводится сообщение:
D/AndroidSocialNetworks﹕ com.github.gorbin.asne.odnoklassniki.OkSocialNetwork@5351f1fchandleRequestResult: Bundle[...] : SocialNetwork.REQUEST_GET_DETAIL_PERSON
со всем содержимым SocialPerson в том числе с токеном - это серьезная дыра в безопасности

С приветом,
Олег

translate:

After login in Odnoklassniki there is log with all personal information about user - big security error

Update asne-googleplus dependencies

It depends on com.google.android.gms:play-services:4.3.23. Apps which user newer versions will get gradle errors: "more than one library with package name 'com.google.android.gms'"

This should be replaced with the newer libraries:
com.google.android.gms:play-services-base:6.5.87
com.google.android.gms:play-services-plus:6.5.87

How set token to SocialNetwork?

Hi!

My app receive token, expired time and other (witch were save before) from server side, and I want to initialize SocialNetwork object with received tokens. May be, you add this function to SocialNetwork class?

uses-sdk element cannot have a "tools:node" attribute

I've updated Android Studio to version 0.9, and gradle build tools to version 0.14, now when i try to build my application (which is using ASNE) I got this error:

Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : uses-sdk element cannot have a "tools:node" attribute

I've searched in my code, and I'm not using tools:node="replace" anywhere, but ASNE is using in manifest (both in core and "modules").

Any idea how I can solve this problem?

What about requestGetPhotos?

I'm trying to get photos of my friends and there are not such method in ASNE.
Now i need to write my own code. For example:

final VKRequest request = new VKRequest("photos.getAll", VKParameters.from(VKApiConst.OWNER_ID, friendId, VKApiConst.COUNT, 200));
                request.executeWithListener(vkRequestListener);

But it's hard to make same request to Instagram. And it requires to define own SocialNetwork class like MyInstagram. Didn't chek other social networks.

[ASNETutorial]Application always crashing after changing orientation (rotating device)

Hello again.

How to reproduce bug:
Open example project (https://github.com/gorbin/ASNETutorial) on device, rotate device at least once and then press any of the social buttons.

Result for facebook:

Process: com.github.gorbin.asnetutorial, PID: 13770
    java.lang.NullPointerException
            at com.facebook.Session$AuthorizationRequest$1.startActivityForResult(Session.java:1902)
            at com.facebook.Session.tryLoginActivity(Session.java:1409)
            at com.facebook.Session.authorize(Session.java:1159)
            at com.facebook.Session.open(Session.java:1237)
            at com.facebook.Session.openForRead(Session.java:471)
            at com.github.gorbin.asne.facebook.FacebookSocialNetwork.requestLogin(FacebookSocialNetwork.java:149)
            at com.github.gorbin.asne.core.SocialNetwork.requestLogin(SocialNetwork.java:205)
            at com.github.gorbin.asnetutorial.MainFragment$1.onClick(MainFragment.java:160)
            at android.view.View.performClick(View.java:4658)
            at android.view.View$PerformClick.run(View.java:19461)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5653)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)

For VKontakte will be something like

Caused by: java.lang.NullPointerException: Argument 'currentActivity' cannot be null
            at com.facebook.internal.Validate.notNull(Validate.java:29)
            at com.facebook.Session.onActivityResult(Session.java:723)
            at com.github.gorbin.asne.facebook.FacebookSocialNetwork.onActivityResult(FacebookSocialNetwork.java:535)
            at com.github.gorbin.asne.core.SocialNetworkManager.onActivityResult(SocialNetworkManager.java:92)
            at ru.**MyPackage***.MyLoginActivity.onActivityResult(LoginActivity.java:75)
            at android.app.Activity.dispatchActivityResult(Activity.java:5734)
            at android.app.ActivityThread.deliverResults(ActivityThread.java:3696)
            at android.app.ActivityThread.handleSendResult(ActivityThread.java:3743)
            at android.app.ActivityThread.access$1400(ActivityThread.java:172)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:146)
            at android.app.ActivityThread.main(ActivityThread.java:5653)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
            at dalvik.system.NativeStart.main(Native Method)

after finishing fragment.

null pointer when request for gplus friends

java.lang.NullPointerException
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.getSocialPerson(GooglePlusSocialNetwork.java:341)
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.access$300(GooglePlusSocialNetwork.java:70)
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork$5.onResult(GooglePlusSocialNetwork.java:482)
at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork$5.onResult(GooglePlusSocialNetwork.java:474)
at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.deliverResultCallback(Unknown Source)
at com.google.android.gms.common.api.BaseImplementation$CallbackHandler.handleMessage(Unknown Source)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5139)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)

Facebook access token

Facebook access token is blank string. how can i get it? i have done login, than i ask it with requestAccessToken(callback), but in onRequestAccessTokenComplete token is blank

Error : null Toast on facebook login

Prerequisits :

  1. Facebook app
  2. Facebook account with app platform turned off

Steps to reproduce :

  1. Select facebook login from the app using ASNE
  2. Facebook app loads and asks to 'Turn on platform'
  3. Click 'Cancel' button

Can you send any other errorMessage in onError()

Logout from another fragment

It seems that it's currently not possible to logout from another fragment.

e.q. when using GooglePlusSocialNetwork. It seems that the GoogleClientApi is required to be connected before we can log out.
However, since i am using it from another fragment the Google Client API is not connected and thus, not possible to logout.

Google Cross-client Identity

Hello! First of all, thanks for a great lib! :)

We are trying to implement Cross-client Identity so we can use the same client_id in web and android apps. To do so, we need to send a special scope while doing login.

Normally, when you ask for an OAuth token, the person using the device sees a challenge, asking them if it’s OK to use their identity to get at some resource or other. But in this case, the system looks at the server-side Client ID in your scope argument, notices that it’s in the same project as your Android app, and gives you the token without pestering the user; they’ve already agreed to a relationship with you, the developer who controls that project. " Source

That being said, we need to send audience:server:client_id:X, where X is the Client ID of for the Web app.

As far as we could see, we cannot change the scope it's used while getting token

token = GoogleAuthUtil.getToken(params[0],
Plus.AccountApi.getAccountName(googleApiClient), scope);

Are you planning to add a way to do so? Do you want us to do a pull request?

FirstName and LastName for VkPerson

You get first name and last name for person from server separately. Can you add them to VkPerson class?

VkSocialNetwork.getSocialPerson()

 if(jsonResponse.has("first_name")) {
    firstName = jsonResponse.getString("first_name");
 }
 if(jsonResponse.has("last_name")) {
        lastName = jsonResponse.getString("last_name");
 }
 socialPerson.name = firstName + " " + lastName;

Maybe type conversion needed

I can't override onError for OnRequestAccessTokenCompleteListener.
Could you check if G+ generates access token for you once more please?

Twitter Access Token

Hello.

I have a problem getting Twitter Access Token. Basically, this is the function I call on my "onLoginSucess" callback:

AccessToken token = network.getAccessToken();

And then I use token.token and token.secret. But this fields are null.

For example, if I print: token.toString()

AccessToken{token='', secret='null'}

The logcat for this code is:

[INFO:CONSOLE(8)] "The value "device-width;" for key "width" is invalid, and has been ignored.", source: https://api.twitter.com/oauth/authenticate (8)
[INFO:CONSOLE(8)] "The value "1.0;" for key "initial-scale" was truncated to its numeric prefix.", source: https://api.twitter.com/oauth/authenticate (8)
[INFO:CONSOLE(8)] "The value "1.0;" for key "maximum-scale" was truncated to its numeric prefix.", source: https://api.twitter.com/oauth/authenticate (8)
[INFO:CONSOLE(8)] "Error parsing a meta element's content: ';' is not a valid key-value pair separator. Please use ',' instead.", source: https://api.twitter.com/oauth/authenticate (8)

I don't know if I'm doing something wrong.

Thanks.

invite friend

Было бы неплохо реализовать возможность приглашать друзей в приложение.

Add language selection for VKRequests

VK SDK class VKRequest provides method setPreferredLang(String lang) and also has field useSystemLang that currently set to false in the source code of class VkSocialNetwork.java, that leads up to results from VK in English, though it is necessarily to get results in Russian

LinkedIn login "invalid uri"

When trying to login with linkedIn. I get error message "invalid redirect_uri. This value must match a URL registered with the API Key." in the webview.

NoSuchMethodError with GooglePlusSocialNetwork

I get an exception using GooglePlusSocialNetwork. With Facebook all works fine but when i add

GooglePlusSocialNetwork googleNetwork = new GooglePlusSocialNetwork(this);
mSocialNetworkManager.addSocialNetwork(googleNetwork);

my app crash with this exception:

java.lang.NoSuchMethodError: com.google.android.gms.common.api.GoogleApiClient$Builder.addApi
        at com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.onCreate(GooglePlusSocialNetwork.java:546)
        at com.github.gorbin.asne.core.SocialNetworkManager.onCreate(SocialNetworkManager.java:56)
        at android.support.v4.app.Fragment.performCreate(Fragment.java:1763)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:913)
        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
        at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
        at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
        at android.app.Activity.performStart(Activity.java:5143)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
        at android.app.ActivityThread.access$600(ActivityThread.java:141)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5103)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)

when try to get fb friends

java.lang.NullPointerException
at com.github.gorbin.asne.facebook.FacebookSocialNetwork$5.onCompleted(FacebookSocialNetwork.java:510)
at com.facebook.Request$2.onCompleted(Request.java:302)
at com.facebook.Request$4.run(Request.java:1666)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5139)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:611)
at dalvik.system.NativeStart.main(Native Method)

Google Plus Access Token Cache issue

If a user receives an access token but does not complete the login until it expires, the user will not be able to log in. This could also be seen if the user revokes the access token. This is due to the GoogleAuthUtil caching the access token on the device for an unknown period of time.

In the code written below, the access token is checked for validity, and if not valid, it will clear the cached token and request a new one.

I can send in a pull request if you would like.

   @Override
public void requestAccessToken(OnRequestAccessTokenCompleteListener onRequestAccessTokenCompleteListener) {
    super.requestAccessToken(onRequestAccessTokenCompleteListener);

    AsyncTask<Activity, Void, String> task = new AsyncTask<Activity, Void, String>() {
        @Override
        protected String doInBackground(Activity... params) {
            String scope = "oauth2:" + Scopes.PLUS_LOGIN;
            String token;
            String error = null;
            try {
                token = GoogleAuthUtil.getToken(params[0],
                        Plus.AccountApi.getAccountName(googleApiClient), scope);

                try {
                    HttpParams httpParameters = new BasicHttpParams();
                    HttpConnectionParams.setConnectionTimeout(httpParameters, 20000);
                    HttpConnectionParams.setSoTimeout(httpParameters, 20000);
                    HttpClient client = new DefaultHttpClient(httpParameters);
                    String url = "https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=" + token;

                    HttpGet httpGet = new HttpGet(url);

                    HttpResponse response = client.execute(httpGet);
                    BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
                    StringBuilder builder = new StringBuilder();
                    for (String line = null; (line = reader.readLine()) != null; ) {
                        builder.append(line).append("\n");
                    }

                    JSONTokener tokener = new JSONTokener(builder.toString());
                    JSONObject finalResult = new JSONObject(tokener);
                    error = finalResult.getString("error");
                } catch (Exception e) {
                    //Probably shouldn't use Exception E here but there are quite a few
                    //http/io/json exceptions that could occur
                }

                if (error != null && error.equals("invalid_token")) {
                    GoogleAuthUtil.clearToken(params[0], token);
                    token = GoogleAuthUtil.getToken(params[0],
                            Plus.AccountApi.getAccountName(googleApiClient), scope);
                }

            } catch (Exception e) {
                e.printStackTrace();
                return e.getMessage();
            }
            return token;
        }

        @Override
        protected void onPostExecute(String token) {
            if(token != null) {
                ((OnRequestAccessTokenCompleteListener) mLocalListeners.get(REQUEST_ACCESS_TOKEN))
                        .onRequestAccessTokenComplete(getID(), new AccessToken(token, null));
            } else {
                mLocalListeners.get(REQUEST_ACCESS_TOKEN).onError(getID(), REQUEST_ACCESS_TOKEN, token, null);
            }
        }
    };
    task.execute(mActivity);
}

FacebookPerson.city is null

From @basnopisets,

И еще один момент - почему-то при запросе детальной информации с FB city приходит пустым, хотя в профиле город указан

translete:

And one more thing - there is null in city from FacebookPerson, but in profile city is set

AvatarUrl for Vk account is null

I tried to load avatar for Vk account and found that avatarUrl property is always null.
After some time I found that method VkSocialNetwork.getSocialPerson searches only for "photo_200". I solved the problem by adding this code, maybe this code is more common for getting avatar url:

private SocialPerson getSocialPerson(SocialPerson socialPerson, JSONObject jsonResponse) 
throws JSONException {
...
if (jsonResponse.has("photo_max_orig")) {
         socialPerson.avatarURL = jsonResponse.getString("photo_max_orig");
}
...
}

Option for disabling AlertDialog on VK errors

Please give us option to disable AlertDialog (or manually handling errors) during VK authorization. I'm talking about VkSocialNetwork.java:107

   @Override
   public void onAccessDenied(VKError authorizationError) {
      new AlertDialog.Builder(VKUIHelper.getTopActivity())
      .setMessage(authorizationError.toString())
      .show();
   }

I would like if method onError(int networkId, String requestID, String errorMessage, Object data) be called for listeners instead.

Get a token to be sent and used by the server

Hi,

I need to get a token which will be sent to the server and used there to get the user's information.

From my understanding LinkedIn uses a different token for this situation. Is it possible to get this token using ASNE?

import error

Hi, I'm writing compile 'com.github.asne:asne-twitter:0.2.1' and I get the following error:
FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':pettoyou'.

    Could not resolve all dependencies for configuration ':pettoyou:_defaultFlavorDebugCompile'.
    Could not find com.github.asne:ASNECore:0.2.1.
    Required by:
    pettoyouandroid:pettoyou:unspecified > com.github.asne:asne-twitter:0.2.1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

how can I be???

shared post id

Добавь пожалуйста возможность получать id отправленного поста.

Using ASNE library from activity, not from fragment

I integratin ASNE library in a base activity that let use login in all the screens of the application.

The problem is that SocialNetwork inicialization needs a Fragment to be instanciate.

I can instanciate a SocialNetwork with the SocialNetworkManager fragment but if I make this:

public final void configureSocialLibrary() {
mSocialNetworkManager = new SocialNetworkManager();
mSocialNetworkManager.addSocialNetwork(getTwitterSocialNetwork());
mSocialNetworkManager.addSocialNetwork(getFacebookSocialNetwork());
mSocialNetworkManager.addSocialNetwork(getGoogleSocialNetwork());
getSupportFragmentManager().beginTransaction().add(mSocialNetworkManager, SOCIAL_TAG).commit();
mSocialNetworkManager.setOnInitializationCompleteListener(this);
}

It crash in the SocialNetwork class trying to get the SharedPreferences.

In the tutorial the solution is pass the Fragment that controls the buttons and that stuff instead of pass the SocialNetworkManager but this is not possible because I dont need Fragments to make the login -- remember I want to make login in every part of the app.

I try, of course, of add the social networks before commit the social manager but doesn't works for evident reasons.

Are there some solution for this or I need to make a fork with a builder with Fragment and Activity to fix the problem?

NullPointerException in SocialNetwork.<init>

I get a NullPoineterEcxeption when I try to instantiate a SocialNetwork.

VkSocialNetwork vk = new VkSocialNetwork(new Fragment(), VK_APP_ID, vkScope);
 java.lang.NullPointerException
            at com.github.gorbin.asne.core.SocialNetwork.<init>(SocialNetwork.java:127)
            at com.github.gorbin.asne.vk.VkSocialNetwork.<init>(VkSocialNetwork.java:142)

Since I don't use any fragments in my app, I've created a separate class for working with ASNE, so I can't pass "this" as first parameter (like in your tutorial) and I've decided to just create a new Fragment. But it doesn't seem to work. I've also tried passing mSocialNetworkManager fragment as first parameter and got the same exception.

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.