{"id":19773174,"url":"https://github.com/ibm-cloud-security/appid-clientsdk-android","last_synced_at":"2025-04-30T18:31:40.305Z","repository":{"id":50124677,"uuid":"75317467","full_name":"ibm-cloud-security/appid-clientsdk-android","owner":"ibm-cloud-security","description":"Android SDK for the Bluemix AppID service","archived":false,"fork":false,"pushed_at":"2021-06-03T15:03:57.000Z","size":825,"stargazers_count":4,"open_issues_count":7,"forks_count":9,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-06T03:41:22.207Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ibm-cloud-security.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-01T17:46:33.000Z","updated_at":"2022-04-06T16:21:01.000Z","dependencies_parsed_at":"2022-09-23T18:40:23.186Z","dependency_job_id":null,"html_url":"https://github.com/ibm-cloud-security/appid-clientsdk-android","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibm-cloud-security%2Fappid-clientsdk-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibm-cloud-security%2Fappid-clientsdk-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibm-cloud-security%2Fappid-clientsdk-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibm-cloud-security%2Fappid-clientsdk-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibm-cloud-security","download_url":"https://codeload.github.com/ibm-cloud-security/appid-clientsdk-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251760930,"owners_count":21639517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T05:08:53.278Z","updated_at":"2025-04-30T18:31:39.988Z","avatar_url":"https://github.com/ibm-cloud-security.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IBM Cloud App ID Android SDK\n\n[![IBM Cloud powered][img-ibmcloud-powered]][url-ibmcloud]\n[![Travis][img-travis-master]][url-travis-master]\n[![Coverage Status][img-coveralls-master]][url-coveralls-master]\n[![Codacy Badge][img-codacy]][url-codacy]\n[![Release](https://jitpack.io/v/ibm-cloud-security/appid-clientsdk-android.svg)](https://jitpack.io/#ibm-cloud-security/appid-clientsdk-android)\n[![License][img-license]][url-bintray]\n\n[![GithubWatch][img-github-watchers]][url-github-watchers]\n[![GithubStars][img-github-stars]][url-github-stars]\n[![GithubForks][img-github-forks]][url-github-forks]\n\n## Requirements\n* API 27 or above\n* Java 8.x\n* Android SDK Tools 26.1.1+\n* Android SDK Platform Tools 27.0.1+\n* Android Build Tools version 27.0.0+\n\n## Installing the SDK:\n1.  Add the JitPack repository to the your root `build.gradle` file at the end of the repository.\n\n```gradle\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\n2. Add the dependency for the App ID client SDK:\n```gradle\ndependencies {\n        compile 'com.github.ibm-cloud-security:appid-clientsdk-android:6.+'\n}\n```\n\n3. Within your Android project in Android Studio, open the build.gradle file of your app module (not the project build.gradle), and add the following line to the defaultConfig:\n```\ndefaultConfig {\n    ...\n    manifestPlaceholders = ['appIdRedirectScheme': android.defaultConfig.applicationId]\n}\n```\n\n## Initializing the App ID Client SDK\n\nInitialize the client SDK by passing the context, tenantId and region parameters to the initialize method. A common, though not mandatory, place to put the initialization code is in the `onCreate` method of the main activity in your Android application.\n```java\nAppID.getInstance().initialize(getApplicationContext(), \u003ctenantId\u003e, AppID.REGION_UK);\n```\n* Replace \"tenantId\" with the App ID service tenantId.\n* Replace the AppID.REGION_UK with your App ID region (AppID.REGION_US_SOUTH, AppID.REGION_SYDNEY).\n\n## Using the Login Widget\nUse the `LoginWidget` class to start the authorization flow.   \n\n```java\nLoginWidget loginWidget = AppID.getInstance().getLoginWidget();\nloginWidget.launch(this, new AuthorizationListener() {\n    @Override\n    public void onAuthorizationFailure (AuthorizationException exception) {\n        //Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationCanceled () {\n        //Authentication canceled by the user\n    }\n\n    @Override\n    public void onAuthorizationSuccess (AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        //User authenticated\n    }\n});\n```\n**Note**:\n\n* By default, App ID is configured to use Facebook, Google, and Cloud Directory as identity providers. If you change your identity provider settings to provide only one option, then the Login Widget is not needed and will not display. The user is directed to your chosen identity provider's authentication screen.\n* When using Cloud Directory, and \"Email verification\" is configured to *not* allow users to sign-in without email verification, then the \"onAuthorizationSuccess\" of the \"AuthorizationListener\" will be invoked without tokens.\n\n## Managing Cloud Directory with the Android SDK\n\n Make sure to set Cloud Directory identity provider to ON in AppID dashboard, when using the following APIs.\n\n### Sign in using Resource Owner Password\n You can obtain access token, id token and refresh token by supplying the end user's username and password.\n```java\nAppID.getInstance().signinWithResourceOwnerPassword(getApplicationContext(), username, password, new TokenResponseListener() {\n    @Override\n    public void onAuthorizationFailure (AuthorizationException exception) {\n        //Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationSuccess (AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        //User authenticated\n    }\n});\n```\n\n### Sign Up\nMake sure to set **Allow users to sign up and reset their password** to **ON**, in the settings for Cloud Directory.\nUse the LoginWidget class to start the sign up flow.\n\n```java\nLoginWidget loginWidget = AppID.getInstance().getLoginWidget();\nloginWidget.launchSignUp(this, new AuthorizationListener() {\n    @Override\n    public void onAuthorizationFailure (AuthorizationException exception) {\n        //Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationCanceled () {\n        //Sign up canceled by the user\n    }\n\n    @Override\n    public void onAuthorizationSuccess (AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        if (accessToken != null \u0026\u0026 identityToken != null) {\n            //User authenticated\n        } else {\n            //email verification is required\n        }\n    }\n});\n```\n### Forgot Password\n  Make sure to set **Allow users to sign up and reset their password** and **Forgot password email** to **ON**, in the settings for Cloud Directory\n\n Use LoginWidget class to start the forgot password flow.\n```java\nLoginWidget loginWidget = AppID.getInstance().getLoginWidget();\nloginWidget.launchForgotPassword(this, new AuthorizationListener() {\n    @Override\n \tpublic void onAuthorizationFailure (AuthorizationException exception) {\n        //Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationCanceled () {\n        // Forogt password canceled by the user\n    }\n\n    @Override\n    public void onAuthorizationSuccess (AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        // Forgot password finished, in this case accessToken and identityToken will be null.\n    }\n});\n```\n### Change Details\n  Make sure to set **Allow users to sign up and reset their password** to **ON**, in Cloud Directory settings that are in AppID dashboard. Use LoginWidget class to start the change details flow. This API can be used only when the user is logged in using Cloud Directory identity provider.\n\n```java\nLoginWidget loginWidget = AppID.getInstance().getLoginWidget();\nloginWidget.launchChangeDetails(this, new AuthorizationListener() {\n    @Override\n    public void onAuthorizationFailure (AuthorizationException exception) {\n        // Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationCanceled () {\n        // Changed details canceled by the user\n    }\n\n    @Override\n    public void onAuthorizationSuccess (AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        // User authenticated, and fresh tokens received\n    }\n});\n```\n### Change Password\n   Make sure to set **Allow users to sign up and reset their password** to **ON**, in the settings for Cloud Directory.\n\n   Use LoginWidget class to start the change password flow. This API can be used only when the user logged in by using Cloud Directory as their identity provider.\n\n```java\nLoginWidget loginWidget = AppID.getInstance().getLoginWidget();\nloginWidget.launchChangePassword(this, new AuthorizationListener() {\n    @Override\n    public void onAuthorizationFailure (AuthorizationException exception) {\n        // Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationCanceled () {\n        // Change password canceled by the user\n    }\n\n    @Override\n    public void onAuthorizationSuccess (AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        // User authenticated, and fresh tokens received\n    }\n});\n```\n\n## Anonymous Sign in\n```java\nAppID.getInstance().signinAnonymously(getApplicationContext(), new AuthorizationListener() {\n    @Override\n    public void onAuthorizationFailure(AuthorizationException exception) {\n        //Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationCanceled() {\n        //Authentication canceled by the user\n    }\n\n    @Override\n    public void onAuthorizationSuccess(AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        //User authenticated\n    }\n});\n```\n\n## Sign in with refresh token\nIt is recommended to store the refresh token locally such that it will be possible to sign in with the refresh token without requiring the user to type his credentials again.\n\n```java\nAppID.getInstance().signinWithRefreshToken(getApplicationContext(), refreshTokenString, new AuthorizationListener() {\n    @Override\n    public void onAuthorizationFailure(AuthorizationException exception) {\n        //Exception occurred\n    }\n\n    @Override\n    public void onAuthorizationCanceled() {\n        //Authentication canceled by the user\n    }\n\n    @Override\n    public void onAuthorizationSuccess(AccessToken accessToken, IdentityToken identityToken, RefreshToken refreshToken) {\n        //User authenticated\n    }\n});\n```\n\n## Logout\nCall the logout function in order to clear the stored tokens.\n```java\nAppID.getInstance().logout();\n```\n\n## Manage User Profiles\n\nUsing the App ID UserProfileManager, you are able to create, delete, and retrieve user profile attributes as well as get additional info about a user.\n\n```java\nAppID appId = AppID.getInstance();\nString name = \"name\";\nString value = \"value\";\n\nappId.getUserProfileManager().setAttribute(name, value, new UserProfileResponseListener() {\n    @Override\n    public void onSuccess(JSONObject attributes) {\n        // Set attribute \"name\" to \"value\" successfully\n    }\n\n    @Override\n    public void onFailure(UserAttributesException e) {\n        // Exception occurred\n    }\n});\n\nappId.getUserProfileManager().getAttribute(name, new UserProfileResponseListener() {\n    @Override\n    public void onSuccess(JSONObject attributes) {\n        // Got attribute \"name\" successfully\n    }\n\n    @Override\n    public void onFailure(UserAttributesException e) {\n        // Exception occurred\n    }\n});\n\nappId.getUserProfileManager().getAllAttributes(new UserProfileResponseListener() {\n    @Override\n    public void onSuccess(JSONObject attributes) {\n        // Got all attributes successfully\n    }\n\n    @Override\n    public void onFailure(UserAttributesException e) {\n        // Exception occurred\n    }\n});\n\nappId.getUserProfileManager().deleteAttribute(name, new UserProfileResponseListener() {\n    @Override\n    public void onSuccess(JSONObject attributes) {\n        // Attribute \"name\" deleted successfully\n    }\n\n    @Override\n    public void onFailure(UserAttributesException e) {\n        // Exception occurred\n    }\n});\n\n// Retrieve user info using the latest stores access and identity tokens\nappId.getUserProfileManager().getUserInfo(new UserProfileResponseListener() {\n    @Override\n    public void onSuccess(JSONObject userInfo) {\n        // retrieved user info successfully\n    }\n\n    @Override\n    public void onFailure(UserInfoException e) {\n        // Exception occurred\n    }\n});\n\n// Retrieve user info using your own accessToken.\n// Optionally, pass an identityToken for response verification. (recommended)\nappId.getUserProfileManager().getUserInfo(accessToken, identityToken, new UserProfileResponseListener() {\n    @Override\n    public void onSuccess(JSONObject userInfo) {\n        // retrieved user info successfully\n    }\n\n    @Override\n    public void onFailure(UserInfoException e) {\n        // Exception occurred\n    }\n});\n```\n\n## Invoking protected resources\n```java\nBMSClient bmsClient = BMSClient.getInstance();\nbmsClient.initialize(getApplicationContext(), AppID.REGION_UK);\n\nAppIDAuthorizationManager appIdAuthMgr = new AppIDAuthorizationManager(AppID.getInstance())\nbmsClient.setAuthorizationManager(appIdAuthMgr);\n\nRequest request = new Request(\"http://my-mobile-backend.mybluemix.net/protected\", Request.GET);\nrequest.send(this, new ResponseListener() {\n\n@Override\npublic void onSuccess (Response response) {\n    Log.d(\"Myapp\", \"onRegistrationSuccess :: \" + response.getResponseText());\n}\n\n@Override\npublic void onFailure (Response response, Throwable t, JSONObject extendedInfo) {\n    if (null != t) {\n        Log.d(\"Myapp\", \"onRegistrationFailure :: \" + t.getMessage());\n    } else if (null != extendedInfo) {\n        Log.d(\"Myapp\", \"onRegistrationFailure :: \" + extendedInfo.toString());\n    } else {\n        Log.d(\"Myapp\", \"onRegistrationFailure :: \" + response.getResponseText());\n        }\n    }\n});\n```\n\n## Got Questions?\nJoin us on [Slack](https://www.ibm.com/cloud/blog/announcements/get-help-with-ibm-cloud-app-id-related-questions-on-slack) and chat with our dev team.\n\n## License\nThis package contains code licensed under the Apache License, Version 2.0 (the \"License\"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 and may also view the License in the LICENSE file within this package.\n\n[img-ibmcloud-powered]: https://img.shields.io/badge/ibm%20cloud-powered-blue.svg\n[url-ibmcloud]: https://www.ibm.com/cloud/\n[url-bintray]: https://bintray.com/ibmcloudsecurity/appid-clientsdk-android\n[img-license]: https://img.shields.io/github/license/ibm-cloud-security/appid-clientsdk-android.svg\n[img-version]: https://img.shields.io/bintray/v/ibmcloudsecurity/maven/appid-clientsdk-android.svg\n\n[img-github-watchers]: https://img.shields.io/github/watchers/ibm-cloud-security/appid-clientsdk-android.svg?style=social\u0026label=Watch\n[url-github-watchers]: https://github.com/ibm-cloud-security/appid-clientsdk-android/watchers\n[img-github-stars]: https://img.shields.io/github/stars/ibm-cloud-security/appid-clientsdk-android.svg?style=social\u0026label=Star\n[url-github-stars]: https://github.com/ibm-cloud-security/appid-clientsdk-android/stargazers\n[img-github-forks]: https://img.shields.io/github/forks/ibm-cloud-security/appid-clientsdk-android.svg?style=social\u0026label=Fork\n[url-github-forks]: https://github.com/ibm-cloud-security/appid-clientsdk-android/network\n\n[img-travis-master]: https://travis-ci.org/ibm-cloud-security/appid-clientsdk-android.svg\n[url-travis-master]: https://travis-ci.org/ibm-cloud-security/appid-clientsdk-android\n\n[img-coveralls-master]: https://coveralls.io/repos/github/ibm-cloud-security/appid-clientsdk-android/badge.svg?branch=master\n[url-coveralls-master]: https://coveralls.io/github/ibm-cloud-security/appid-clientsdk-android?branch=master\n\n[img-codacy]: https://api.codacy.com/project/badge/Grade/be6f5f4cdae446909279d014bc650b1b\n[url-codacy]: https://www.codacy.com/app/rotembr/appid-clientsdk-android?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=ibm-cloud-security/appid-clientsdk-android\u0026amp;utm_campaign=Badge_Grad\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibm-cloud-security%2Fappid-clientsdk-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibm-cloud-security%2Fappid-clientsdk-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibm-cloud-security%2Fappid-clientsdk-android/lists"}