Skip to content

pavel163/SocialAuth

Repository files navigation

SocialAuth

A library that helps to implement social network authorization (Facebook, Twitter, Instagram, GooglePlus, VK).

###Twitter Create new application at https://apps.twitter.com

Download via Gradle:

compile 'com.github.pavel163.SocialAuth:twitter:1.0.4'

In strings.xml

<string name="twitter_consumer_key">your_consumer_key</string>
<string name="twitter_consumer_secret">your_consumer_secret</string>

If you don't use fabric plugin for Android studio, put it into gradle:

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

And look at an example (May be a fragment instead of activity) TwitterActivity

###Facebook Create new application at https://developers.facebook.com/apps
Download via Gradle:

compile 'com.github.pavel163.SocialAuth:facebook:1.0.4'

In strings.xml

<string name="facebook_app_id">your_app_id</string>

Add the Maven Central Repository to build.gradle before dependencies:

repositories {
   mavenCentral()
}

Add a meta-data element to the application element:

<application android:label="@string/app_name" ...>
    ...
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
    ...
</application>

And look at an example (May be a fragment instead of activity) FacebookActivity

###VK Create new application at https://vk.com/dev
Download via Gradle:

compile 'com.github.pavel163.SocialAuth:vk:1.0.4'

In integers.xml

<integer name="com_vk_sdk_AppId">your_app_id</integer>

Create Custom Application:

public class BaseApplication extends VkApplication {
    
    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    protected void tokenIsInvalid() {
        // invalid token
    }
}

And look at an example (May be a fragment instead of activity) VkActivity

###Instagram Create new application at https://www.instagram.com/developer/clients/manage/
Don't forget to enable implicit OAuth in application security settings.

Download via Gradle:

compile 'com.github.pavel163.SocialAuth:instagram:1.0.4'

In strings.xml

<string name="instagram_redirect_uri">your_redirect_uri</string>
<string name="instagram_app_id">your_app_id</string>

And look at an example (May be a fragment instead of activity) InstagramActivity

###Google+ Create new application at https://console.developers.google.com/
Don't forget to enable google plus api.

Download via Gradle:

compile 'com.github.pavel163.SocialAuth:google:1.0.4'

In strings.xml

<string name="google_app_id">your_app_id</string>

And look at an example (May be a fragment instead of activity) GooglePlusActivity