@@ -150,13 +150,40 @@ export interface AzureTokenCredentialsOptions {
150150 */
151151 authorizationScheme ?: string ;
152152
153- // TODO: What type should this really have? How is it used?
154153 /**
155- * The token cache. Default value is null .
154+ * The token cache. Default value is MemoryCache from adal .
156155 */
157156 tokenCache ?: any ;
158157}
159158
159+ export interface LoginWithUsernamePasswordOptions extends AzureTokenCredentialsOptions {
160+ /**
161+ * The domain or tenant id containing this application. Default value is 'common'.
162+ */
163+ domain ?: string ;
164+
165+ /**
166+ * The active directory application client id.
167+ * See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net}
168+ * for an example.
169+ */
170+ clientId ?: string
171+ }
172+
173+ export interface DeviceTokenCredentialsOptions extends LoginWithUsernamePasswordOptions {
174+ /**
175+ * The user name for account in the form: '[email protected] '. Default value is '[email protected] '. 176+ */
177+ username ?: string ;
178+ }
179+
180+ export interface InteractiveLoginOptions extends DeviceTokenCredentialsOptions {
181+ /**
182+ * The language code specifying how the message should be localized to. Default value 'en-us'.
183+ */
184+ language ?: string ;
185+ }
186+
160187export class ApplicationTokenCredentials extends msRest . ServiceClientCredentials {
161188 /**
162189 * Creates a new ApplicationTokenCredentials object.
@@ -179,12 +206,79 @@ export class UserTokenCredentials extends msRest.ServiceClientCredentials {
179206 * @param {string } domain The domain or tenant id containing this application.
180207 * @param {string } username The user name for the Organization Id account.
181208 * @param {string } password The password for the Organization Id account.
182- * @param {string } clientRedirectUri The Uri where the user will be redirected after authenticating with AD.
183209 * @param {AzureTokenCredentialsOptions } options Object representing optional parameters.
184210 */
185- constructor ( clientId : string , domain : string , username : string , password : string , clientRedirectUri : string , options ?: AzureTokenCredentialsOptions ) ;
211+ constructor ( clientId : string , domain : string , username : string , password : string , options ?: AzureTokenCredentialsOptions ) ;
212+ }
213+
214+ export class DeviceTokenCredentials extends msRest . ServiceClientCredentials {
215+ /**
216+ * Creates a new DeviceTokenCredentials object.
217+ * @param {DeviceTokenCredentialsOptions } options Object representing optional parameters.
218+ */
219+ constructor ( options ?: DeviceTokenCredentialsOptions ) ;
186220}
187221
188222// TODO: WHAT SHOULD WE EXPOSE HERE?
189223export class BaseResource {
190224}
225+
226+ /**
227+ * Provides a url and code that needs to be copy and pasted in a browser and authenticated over there. If successful, the user will get a
228+ * DeviceTokenCredentials object
229+ *
230+ * @param {InteractiveLoginOptions } [options] The parameter options.
231+ *
232+ * @param {function } callback
233+ *
234+ * @returns {function } callback(err, credentials)
235+ *
236+ * {Error} [err] - The Error object if an error occurred, null otherwise.
237+ *
238+ * {DeviceTokenCredentials} [credentials] - The DeviceTokenCredentials object
239+ */
240+ export function interactiveLogin ( options ?: InteractiveLoginOptions , callback ) ;
241+
242+ /**
243+ * Provides a UserTokenCredentials object. This method is applicable only for organizational ids that are not 2FA enabled.
244+ * Otherwise please use interactive login.
245+ *
246+ * @param {string } username The user name for the Organization Id account.
247+ *
248+ * @param {string } password The password for the Organization Id account.
249+ *
250+ * @param {LoginWithUsernamePasswordOptions } [options] The parameter options.
251+ *
252+ * @param {function } callback
253+ *
254+ * @returns {function } callback(err, credentials)
255+ *
256+ * {Error} [err] - The Error object if an error occurred, null otherwise.
257+ *
258+ * {UserTokenCredentials} [credentials] - The UserTokenCredentials object
259+ */
260+ export function loginWithUsernamePassword ( username : string , password : string , options ?: LoginWithUsernamePasswordOptions , callback ) ;
261+
262+
263+ /**
264+ * Provides an ApplicationTokenCredentials object.
265+ *
266+ * @param {string } clientId The active directory application client id also known as the SPN (ServicePrincipal Name).
267+ * See {@link https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-dotnet/ Active Directory Quickstart for .Net}
268+ * for an example.
269+ *
270+ * @param {string } secret The application secret for the service principal.
271+ *
272+ * @param {string } domain The domain or tenant id containing this application.
273+ *
274+ * @param {AzureTokenCredentialsOptions } [options] The parameter options.
275+ *
276+ * @param {function } callback
277+ *
278+ * @returns {function } callback(err, credentials)
279+ *
280+ * {Error} [err] - The Error object if an error occurred, null otherwise.
281+ *
282+ * {ApplicationTokenCredentials} [credentials] - The ApplicationTokenCredentials object
283+ */
284+ export function loginWithServicePrincipalSecret ( clientId : string , secret : string , domain : string , options ?: AzureTokenCredentialsOptions , callback ) ;
0 commit comments