none
Accessing One Drive for Business programmatically with harcoded credentials (no login prompt) RRS feed

  • Question

  • I am developing an web app to show all the content (files & folders) from One Drive account.

    Currently, I am using ADAL.js library for getting the content from one drive for business. However, it prompts for login screen.

    I somehow want to give these credentials in config file or I need to pass these credentials programatically (hardcoded).

    Can anyone help me with this requirement ?

    Thanks in advance

    Tuesday, April 26, 2016 12:13 PM

All replies

  • Good timing! I have similar question. I would like to access drive and email (and others) from an app but I would like to use my own form to collect credentials from user to login.

    In short, I would like to use simple REST client like postman to get authorization code and access token and access the required resource like drive or email.

    Is this possible?

    Thanks and Regards,

    krishna

    Tuesday, April 26, 2016 4:19 PM
  • Looks like this is not possible. Only the trusted authority (which is Azure) has to know the credentials for security. So, you cannot pass something hard coded or you cannot have your own form to pass the credentials.

    If you really want to access without needing user credentials, you can try using App-only approach provided with Graph API. But unfortunately, drive APIs are not yet covered in app-only approach. It will be added in future.

    More here: http://stackoverflow.com/questions/36890014/accessing-microsoft-graph-api-without-using-login-page


    Tuesday, May 3, 2016 8:55 AM
  • Hi Dipendra,

    The OAuth 2.0 do support using resource owner password credentials, however the credentials should only be used when there is a high degree of trust between the resource owner and the client (e.g., the client is part of the device operating system or a highly privileged application), and when other authorization grant types are not available (such as an authorization code).

    This scenario doesn’t apply to using ADAL.JS to authentication in web browser. The following diagram illustrates the Authorization Code Grant flow.

    When we use OAuth 2.0, if you  want the web app can access the resource without users login again, you can store the refresh token and renew the access token when it is expired.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 4, 2016 1:30 AM
    Moderator
  • Hi Fei,

    I am finding this solution for the longest time. If possible could you please lead me to a code resource on how to implement this in c# . This is because Dipendra, i need to fully automate the login process without being directed to a MS login prompt in order to obtain the token. 

    I have been searching for the example codes etc like in Github but yet to find any. 

    So if you could be so kind please share.

    Thank you

    Monday, March 30, 2020 3:36 PM