API Alfresco desde angular

cancel
Showing results for 
Search instead for 
Did you mean: 
nalvarez_colesc
Active Member II

API Alfresco desde angular

Hola, muy buenos dias, estoy queriendo utilizar la API de alfresco desde un proyecto en Angular, y no logro comenzar, entiendo que esto va a molestar ( xq siempre pregunto estas cosas =(    ), pero la verdad que no puedo arrancar, alguien me podria ayudar, aun que sea a iniciarme? Estoy siguiendo unos ejemplos desde la documentacion y otros de internet y no logro hacer que me haga login....

por el momento, solo quiero que responda ok una prueba, les dejo el servicio con el que estoy probando:

import { Injectable } from '@angular/core';
import { AlfrescoApi } from '@alfresco/js-api';

@Injectable({
providedIn: 'root'
})
export class AlfrescoService {

public Api: any;

constructor( ) {}

loginAlfresco() {
// this.Api = new AlfrescoApi();
this.Api = new AlfrescoApi({ provider: 'ECM', authType: 'oauth2', hostEcm: 'http://localhost:8080' });
console.log("Corri");
// tslint:disable-next-lineSmiley Surprisednly-arrow-functions
this.Api.login('admin', 'adminpwd').then(function(data: string) {
console.log('API llamada OK' + data);
// tslint:disable-next-lineSmiley Surprisednly-arrow-functions
}, function(error) {
console.error(error);
});
}

}

Y ahora el componente con el que lo llamo:

import { Component } from '@angular/core';
import { AlfrescoService } from './servicios/alfresco.service';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [ AlfrescoService ],
})
export class AppComponent {
title = 'pruebaapi';

constructor( private api: AlfrescoService) {

this.api.loginAlfresco();

}
}

 

El error que me da es el siguiente:

OPTIONS http://localhost:8080/alfresco/api/-default-/public/authentication/versions/1/tickets 401 (No Autorizado)
scheduleTask @ zone.js:3243
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:410
onScheduleTask @ zone.js:301
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:404
push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:238
push../node_modules/zone.js/dist/zone.js.Zone.scheduleMacroTask @ zone.js:261
scheduleMacroTaskWithCurrentZone @ zone.js:1245
(anonymous) @ zone.js:3276
proto.<computed> @ zone.js:1569
push../node_modules/superagent/lib/client.js.Request._end @ client.js:772
push../node_modules/superagent/lib/client.js.Request.end @ client.js:676
(anonymous) @ alfrescoApiClient.js:219
ZoneAwarePromise @ zone.js:910
push../node_modules/@alfresco/js-api/_esm5/src/alfrescoApiClient.js.AlfrescoApiClient.callHostApi @ alfrescoApiClient.js:218
push../node_modules/@alfresco/js-api/_esm5/src/alfrescoApiClient.js.AlfrescoApiClient.callApi @ alfrescoApiClient.js:204
push../node_modules/@alfresco/js-api/_esm5/src/api/auth-rest-api/api/authentication.api.js.AuthenticationApi.createTicket @ authentication.api.js:37
(anonymous) @ contentAuth.js:66
ZoneAwarePromise @ zone.js:910
push../node_modules/@alfresco/js-api/_esm5/src/authentication/contentAuth.js.ContentAuth.login @ contentAuth.js:65
push../node_modules/@alfresco/js-api/_esm5/src/alfrescoApi.js.AlfrescoApi.login @ alfrescoApi.js:217
push../src/app/servicios/alfresco.service.ts.AlfrescoService.loginAlfresco @ alfresco.service.ts:19
AppComponent @ app.component.ts:15
createClass @ core.js:22150
createDirectiveInstance @ core.js:22029
createViewNodes @ core.js:23255
createRootView @ core.js:23169
callWithDebugContext @ core.js:24177
debugCreateRootView @ core.js:23687
push../node_modules/@angular/core/fesm5/core.js.ComponentFactory_.create @ core.js:21508
push../node_modules/@angular/core/fesm5/core.js.ComponentFactoryBoundToModule.create @ core.js:9935
push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.bootstrap @ core.js:18088
(anonymous) @ core.js:17808
push../node_modules/@angular/core/fesm5/core.js.PlatformRef._moduleDoBootstrap @ core.js:17808
(anonymous) @ core.js:17776
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391
onInvoke @ core.js:17299
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:390
push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:150
(anonymous) @ zone.js:889
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:423
onInvokeTask @ core.js:17290
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:422
push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:195
drainMicroTaskQueue @ zone.js:601
Promise.then (async)
scheduleMicroTask @ zone.js:584
push../node_modules/zone.js/dist/zone.js.ZoneDelegate.scheduleTask @ zone.js:413
push../node_modules/zone.js/dist/zone.js.Zone.scheduleTask @ zone.js:238
push../node_modules/zone.js/dist/zone.js.Zone.scheduleMicroTask @ zone.js:258
scheduleResolveOrReject @ zone.js:879
ZoneAwarePromise.then @ zone.js:1012
push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule @ core.js:17803
./src/main.ts @ main.ts:11
__webpack_require__ @ bootstrap:78
0 @ main.ts:12
__webpack_require__ @ bootstrap:78
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1
Show 14 more frames
localhost/:1 Access to XMLHttpRequest at 'http://localhost:8080/alfresco/api/-default-/public/authentication/versions/1/tickets' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

1 Reply
nalvarez_colesc
Active Member II

Re: API Alfresco desde angular

Nadie ???? Sigo con Problemas   =(