Code Monkey home page Code Monkey logo

microsoftgraph / android-java-connect-sample Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 20.0 916 KB

Use Microsoft Graph to access a user’s Microsoft account data from within an Android app. This sample uses the Microsoft Graph Client Library to work with the data, and uses the Azure AD v2.0 endpoint for authentication of users of personal or work or school accounts.

Home Page: http://graph.microsoft.io/

License: MIT License

Java 98.44% Shell 0.75% Batchfile 0.82%
devxsample

android-java-connect-sample's People

Contributors

irvinesunday avatar jasonjoh avatar johnmaustin avatar nokafor avatar o365devx avatar officegsx avatar ricalo avatar v-dobr avatar

Stargazers

 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

android-java-connect-sample's Issues

On press back button device hang.

I am using this app for first time logging. Call Connect() function for signing.
private void connect() {

    // The sample app is having the PII enable setting on the MainActivity. Ideally, app should decide to enable Pii or not,
    // if it's enabled, it should be  the setting when the application is onCreate.
    if (mEnablePiiLogging) {
        Logger.getInstance().setEnablePII(true);
    } else {
        Logger.getInstance().setEnablePII(false);
    }

    AuthenticationManager mgr = AuthenticationManager.getInstance();

      /* Attempt to get a user and acquireTokenSilent
  • If this fails we do an interactive request
    */
    List users = null;

    try {
    users = mgr.getPublicClient().getUsers();

       if (users != null && users.size() == 1) {
     /* We have 1 user */
           mUser = users.get(0);
           mgr.callAcquireTokenSilent(
                   mUser,
                   true,
                   this);
       } else {
     /* We have no user */
    
     /* Let's do an interactive request */
           mgr.callAcquireToken(
                   this,
                   this);
       }
    

    } catch (MsalClientException e) {
    Log.d(TAG, "MSAL Exception Generated while getting users: " + e.toString());
    showConnectErrorUI(e.getMessage());

    } catch (IndexOutOfBoundsException e) {
    Log.d(TAG, "User at this position does not exist: " + e.toString());
    showConnectErrorUI(e.getMessage());

    }catch (IllegalStateException e) {
    Log.d(TAG, "MSAL Exception Generated: " + e.toString());
    showConnectErrorUI(e.getMessage());

    } catch (Exception e) {
    showConnectErrorUI();
    }
    }

from this function it call.
public void callAcquireToken(Activity activity, final MSALAuthenticationCallback authenticationCallback) {
mActivityCallback = authenticationCallback;
mPublicClientApplication.acquireToken(
activity, Constants.SCOPES, getAuthInteractiveCallback());
}
after calling this function i get signing page.

screenshot_2018-03-13-11-50-59 1

after that i click on back button which appear on signing page.
when i click back button device hang after some time get message of not responding. Device back button work perfect but authetication back button is not working .

Not able to detect exchange password change using MSGraph API

I am using this MSConnect sample app to fetch exchange calendars and events. For an authenticated user, events are downloaded using access token but if a user changes its password, we noticed that events continue to get downloaded using previous access token.

I am not sure if we are missing something but we are able to get events with from older access_token/refresh_token even after several days of password update. Is this an expected behavior?

Is there any way to check if user has changed his password through MS Graph Android SDK, so that app can explicitly show login screen to authenticate the user again?

I am using OIDCLib library for authentication.

Thanks In Advance!!

Always prompting login page

When I login, first attempt works as it is supposed. I enter my outlook credentials and I can send an email. If I stop the app and start again, same prompt is called and I need to select my account again before continuing.

Right now, I'm just saving access token received and next time that app is opened I recovered token as:

        AuthenticationManager auth = AuthenticationManager.getInstance();
        auth.setAccessToken(token);

Is there a better way to do it?

Adding attachment to draft message - 422 Unprocessable Entity

Trying to follow example of adding file attachment for created draft message. Getting the error:
422 : Unprocessable Entity

{                                                                                               
   "error": {                                                                                   
      "code": "UnprocessableType",                                                              
      "message": "Cannot process input of abstract type 'Microsoft.OutlookServices.Attachment'",
      "innerError": {                                                                           
         "request-id": "request_id_string",                                  
         "date": "date_string"                                                          
      }                                                                                         
   }                                                                                            
}

Attachment is created the same way as in code example, by FileAttachment object, all fields are filled the same way.
Is there another way to send file attachment in the same POST where draft message is created?

How to manage multiple accounts?

Hello,
when I acquired an access token, is it possible to reconnect later with this one?
By this way, as for the other cloud providers I use in my app, I could manage multiple accounts.
In this post it seems to be possible to realize it but the mentioned method setAccesToken (token) no longer exists?
Thanks.

The sample is not working with Android Studio emulators.

As in title.
The error is that "Chrome is not installed on the device".
Chrome indeed doesn't come installed on the Android Studio emulators. And it is not simple to install it.

What kind of Android sample is this if it is not working with the default IDE and emulator for Android?

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.