Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed build error and AcquireToken function #11

Open
wants to merge 101 commits into
base: master
Choose a base branch
from

Conversation

sureshchahal
Copy link

Fixed acquireToken and build error

@Neil665
Copy link

Neil665 commented Aug 22, 2016

Hi sureshchahal, thanks for adding this functionality! (Thanks also to alenny for the original code!)

I wanted to try out your code so I cloned it from https://github.com/sureshchahal/angular2-adal and then I ran 'npm install' and 'gulp build'. I got errors because there were two TypeScript declaration files for adal.js, so I removed the line in typings.json so I was only left with the one under 'src\adal'. However there were still a number of build errors, as shown below. Were you using a more updated declaration file for adal.js?

[16:39:17] Using gulpfile ~\git\sureshchahal\angular2-adal\gulpfile.js
[16:39:17] Starting 'build'...
[16:39:17] Starting 'clean:dist'...
[16:39:17] Finished 'clean:dist' after 9.92 ms
[16:39:17] Starting 'readme:dist'...
[16:39:17] Starting 'scripts:cjs'...
[16:39:17] Starting 'scripts:ts'...
[16:39:17] Finished 'readme:dist' after 260 ms
src\services\adal.service.ts(37,16): error TS2339: Property 'AuthenticationContext' does not exist on type 'Window'.
src\services\adal.service.ts(72,34): error TS2339: Property 'callback' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(72,59): error TS2339: Property 'callBackMappedToRenewStates' does not exist on type 'Window'.
src\services\adal.service.ts(77,45): error TS2339: Property 'callback' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(84,46): error TS2339: Property 'callback' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(84,72): error TS2339: Property '_getItem' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(84,98): error TS2339: Property 'CONSTANTS' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(89,46): error TS2339: Property 'callback' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(89,72): error TS2339: Property '_getItem' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(89,98): error TS2339: Property 'CONSTANTS' does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(90,46): error TS2339: Property '_renewFailed' does not exist on type 'AuthenticationContext'.
src\services\authHttp.service.ts(2,39): error TS2307: Cannot find module '@angular/http'.
src\services\authHttp.service.ts(3,27): error TS2307: Cannot find module 'angular2-adal/core'.
[16:39:21] TypeScript: 13 semantic errors
[16:39:21] TypeScript: emit succeeded (with errors)
[16:39:21] Finished 'scripts:ts' after 4.63 s
[16:39:21] Finished 'scripts:cjs' after 4.72 s
[16:39:21] Starting 'scripts'...
[16:39:21] Finished 'scripts' after 4.03 μs
[16:39:21] Starting 'bundle:cjs'...
[16:39:23] Starting 'bundle:cjs:min'...
[16:39:45] Finished 'bundle:cjs' after 24 s
[16:39:45] Finished 'bundle:cjs:min' after 23 s
[16:39:45] Starting 'bundle'...
[16:39:45] Finished 'bundle' after 5.87 μs
[16:39:45] Starting 'copy-typings'...
[16:39:45] Finished 'copy-typings' after 2.92 ms
[16:39:45] Starting 'create-package-json'...
[16:39:45] Finished 'create-package-json' after 6.28 ms
[16:39:45] Finished 'build' after 29 s

@sureshchahal
Copy link
Author

I have fixed those errors. Also provided AuthHttp class. This will acquire
token behind the scene and set header of request. It also work for external
API, if you specify those in config.

On Mon, Aug 22, 2016 at 2:06 AM, Neil665 [email protected] wrote:

Hi sureshchahal, thanks for adding this functionality! (Thanks also to
alenny for the original code!)

I wanted to try out your code so I cloned it from https://github.com/
sureshchahal/angular2-adal and then I ran 'npm install' and 'gulp build'.
I got errors because there were two TypeScript declaration files for
adal.js, so I removed the line in typings.json so I was only left with the
one under 'src\adal'. However there were still a number of build errors, as
shown below. Were you using a more updated declaration file for adal.js?

[16:39:17] Using gulpfile ~\git\sureshchahal\angular2-adal\gulpfile.js
[16:39:17] Starting 'build'...
[16:39:17] Starting 'clean:dist'...
[16:39:17] Finished 'clean:dist' after 9.92 ms
[16:39:17] Starting 'readme:dist'...
[16:39:17] Starting 'scripts:cjs'...
[16:39:17] Starting 'scripts:ts'...
[16:39:17] Finished 'readme:dist' after 260 ms
src\services\adal.service.ts(37,16): error TS2339: Property
'AuthenticationContext' does not exist on type 'Window'.
src\services\adal.service.ts(72,34): error TS2339: Property 'callback'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(72,59): error TS2339: Property
'callBackMappedToRenewStates' does not exist on type 'Window'.
src\services\adal.service.ts(77,45): error TS2339: Property 'callback'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(84,46): error TS2339: Property 'callback'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(84,72): error TS2339: Property '_getItem'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(84,98): error TS2339: Property 'CONSTANTS'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(89,46): error TS2339: Property 'callback'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(89,72): error TS2339: Property '_getItem'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(89,98): error TS2339: Property 'CONSTANTS'
does not exist on type 'AuthenticationContext'.
src\services\adal.service.ts(90,46): error TS2339: Property
'_renewFailed' does not exist on type 'AuthenticationContext'.
src\services\authHttp.service.ts(2,39): error TS2307: Cannot find module
'@angular/http'.
src\services\authHttp.service.ts(3,27): error TS2307: Cannot find module
'angular2-adal/core'.
[16:39:21] TypeScript: 13 semantic errors
[16:39:21] TypeScript: emit succeeded (with errors)
[16:39:21] Finished 'scripts:ts' after 4.63 s
[16:39:21] Finished 'scripts:cjs' after 4.72 s
[16:39:21] Starting 'scripts'...
[16:39:21] Finished 'scripts' after 4.03 μs
[16:39:21] Starting 'bundle:cjs'...
[16:39:23] Starting 'bundle:cjs:min'...
[16:39:45] Finished 'bundle:cjs' after 24 s
[16:39:45] Finished 'bundle:cjs:min' after 23 s
[16:39:45] Starting 'bundle'...
[16:39:45] Finished 'bundle' after 5.87 μs
[16:39:45] Starting 'copy-typings'...
[16:39:45] Finished 'copy-typings' after 2.92 ms
[16:39:45] Starting 'create-package-json'...
[16:39:45] Finished 'create-package-json' after 6.28 ms
[16:39:45] Finished 'build' after 29 s


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARLaH6RyNkwPkE5BtRUUo8ScOvFVexvbks5qiUqAgaJpZM4JZ97p
.

@Neil665
Copy link

Neil665 commented Aug 24, 2016

Thanks, I've tried it out and it is working well.

@alenny are you thinking of merging this pull request into the main library?

jdkb123 and others added 4 commits August 28, 2016 14:57
AuthHttp takes RequestOptions in get, post, delete just like underlying Http from angular. Makes a copy of the RequestOptions before passing to Http.
AuthHttp can take RequestOptions in http requests
…n adal config

Also fix error if server return 204 status
Copy link

@kaleemxii kaleemxii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this PR Suresh, I was also making something similar to get the acquire token working , and then your PR saved the day..

i hope you get these changes published soon..

@@ -83,7 +112,7 @@ export class AdalService {
cb(tokenOut);
}
});
});
})();
}

public getUser(): Observable<adal.User> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you update the below line
return Observable.bindCallback(function (cb: (u: adal.User) => void) {
to
return Observable.bindCallback((cb: (u: adal.User) => void) => {

as the ts compiler is behaving weirdly with first format and creating a JS of

AdalService.prototype.getUser = function () {
return Observable_1.Observable.bindCallback(function (cb) {
this.adalContext.getUser(function (error, user) {

instead of this

AdalService.prototype.getUser = function () {
    var _this = this;
    return Observable_1.Observable.bindCallback(function (cb) {
        _this.adalContext.getUser(function (error, user) {

which is failing with null reference at this.adalContext.something

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

,private adalService : AdalService
) { }

get(url: string, options?: RequestOptionsArgs): Observable<any> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are making this , it would be really helpful if you can include these methods as well

PATCH
PUT
HEAD

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

var resource = this.adalService.GetResourceForEndpoint(url);
var authenticatedCall = this.http.request(url, options).map(this.extractData).catch(this.handleError);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have this assigning statement only if resource is undefined, rather than overriding it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@kaleemxii
Copy link

@alenny Any plans on merging this and releasing , Eagerly waiting for the release.
Thanks in Advance

@sureshchahal
Copy link
Author

Hello kaleemxii- if you can make these changes and submit a change request
I will be happy to merge these. In case you are unable to make these
changes.. I will be working tonight on this

On Thursday, September 29, 2016, kaleemxii [email protected] wrote:

@alenny https://github.com/alenny Any plans on merging this and
releasing , Eagerly waiting for the release.
Thanks in Advance


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARLaH6VLEUuWTh3jyGwI9BdFi19-fdelks5qvBmKgaJpZM4JZ97p
.

@sureshchahal
Copy link
Author

made the changes. please take latest

On Thu, Sep 29, 2016 at 4:08 PM, suresh chahal [email protected]
wrote:

Hello kaleemxii- if you can make these changes and submit a change request
I will be happy to merge these. In case you are unable to make these
changes.. I will be working tonight on this

On Thursday, September 29, 2016, kaleemxii [email protected]
wrote:

@alenny https://github.com/alenny Any plans on merging this and
releasing , Eagerly waiting for the release.
Thanks in Advance


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARLaH6VLEUuWTh3jyGwI9BdFi19-fdelks5qvBmKgaJpZM4JZ97p
.

@kaleemxii
Copy link

Wow that was quick, appreciate it 👍

@sureshchahal
Copy link
Author

published on NPM: https://www.npmjs.com/package/ng2-adal

On Thu, Sep 29, 2016 at 4:56 PM, kaleemxii [email protected] wrote:

Wow that was quick, appreciate it 👍


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#11 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARLaH5SX6EX6LaZ0E367iHxeT16Vl44Wks5qvCYSgaJpZM4JZ97p
.

@ericivarsson
Copy link

ericivarsson commented Oct 7, 2016

Thanks @sureshchahal, great work. Thanks also to @alenny for the original code.

sureshchahal and others added 30 commits June 28, 2017 09:37
Don´t log errors to console
Fix Throw error AuthHttp.service
The user object is always being defaulted so if (user) will always be true.
For a full description of the problem and suggested fix see #64
Fix reference to this in getUser error
Eliminate dead code in adal.service
Fix Typescript >= 2.4.1 compilation error described on issue #64
Read me for angular 4
bumped version to 2.0 to track angular 4 version.
Added the breaking change notice and improved formatting
Updated README with the new example URL
you get here when calling getUser() before logging in. The adal library then throws 'User information is not available' string
Allow to retrieve login status on adalService asynchronously via observables
this was undefined in getUser error handler
Add angular 5 and replace AuthHttp with new Http Interceptor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.