1

Anyone worked on windows azure with iOS, and how to access the windows azure active directory ... Please help me this below topics what are the values i will set up this below mentioned topic in coding ...

WAAD_LOGIN_URL WAAD_DOMAIN WAAD_CLIENT_ID WAAD_REDIRECT_URI WAAD_RESOURCE WAAD_SERVICE_ENDPOINT

Please provide me the help thanks in advance :)

1 Answers1

1

You may want to check the open source github library for authentication: https://github.com/MSOpenTech/azure-activedirectory-library-for-ios. I am currently the main contributor, so feel free to ask me further questions on the library. The readme file will give you an idea on how to authenticate and start using the provided access token. Here is a sample code for obtaining access token. Keep in mind that access tokens are internally cached, so all you need is to call the acquireTokenWithResource below every time you need it, the library takes care of the authentication (asking user for credentials if needed) and leveraging refresh tokens over the OAuth 2.0 protocol.

ADAuthenticationError *error;
authContext = [ADAuthenticationContext authenticationContextWithAuthority:authority
                                                                    error:&error];

NSURL *redirectUri = [NSURL URLWithString:redirectUriString];
[authContext acquireTokenWithResource:resourceId
                             clientId:clientId
                          redirectUri:redirectUri
                      completionBlock:^(ADAuthenticationResult *result) {
    if (AD_SUCCEEDED != result.status){
        // display error on the screen
        [self showError:result.error.errorDetails];
    }
    else{
        //Use result.accessToken to access any services.
    }
}];
  • Boris, is there any way to acquire a token by passing a username and password to the authority? I'd prefer to have my own login screen than use the web view. Thanks – mike Jun 11 '14 at 15:13
  • 2
    Yes, this is a common ask. I am afraid that the ADAL library that I mentioned above does not support that, although the protocol does. We have filed a feature request on Github to add this support. As ADAL.iOS is all open source, you can simply fork the code and implement the password grant in your copy for now. It shouldn't be that difficult as the code already does all of the protocol work. – Boris Vidolov Jun 12 '14 at 18:53
  • Thanks so much for the reply. I'll look into implementing this – mike Jun 12 '14 at 19:50
  • @BorisVidolov: I have a question. From where I get `resourceId` ? – el.severo Jul 07 '15 at 11:09
  • Take a look at this answer: http://stackoverflow.com/questions/23921884/what-is-the-resource-parameter-in-windows-azure-ad-tenant-application-oauth-2-0 – Rich Randall Jul 10 '15 at 20:50