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

No authorization token was found - Problemas con Token con nuevo codigo #67

Open
hggambaro opened this issue May 6, 2020 · 7 comments

Comments

@hggambaro
Copy link

Hola,
Estoy recibiendo ese mensaje al querer registrar un cliente.

{ UnauthorizedError: No authorization token was found
at Auth0AuthenticationStrategy.middleware [as jwtCheck] (/opt/server/node_modules/express-jwt/lib/index.js:76:21)
at Promise (/opt/server/dist/security/auth0.js:19:18)
at new Promise ()
at Auth0AuthenticationStrategy.authenticate (/opt/server/dist/security/auth0.js:18:16)
at AuthenticateActionProvider.action (/opt/server/node_modules/@loopback/authentication/dist/providers/auth-action.provider.js:48:45)
at process._tickCallback (internal/process/next_tick.js:68:7)
name: 'UnauthorizedError',
message: 'No authorization token was found',
code: 'credentials_required',
status: 401,
inner: { message: 'No authorization token was found' } }

Está esperando el token jwt como dice en AUTH_STRATEGY=auth0-jwt.

Podran indicar como se debe configurar? Muchas gracias.

@antonioparraga
Copy link
Collaborator

Hola, seguramente está usted invocando un inbound protegido?
A que servicio está llamando concretamente?

@hggambaro
Copy link
Author

Esto sucede en la registración de un cliente en la app-citizen.
En la app citizen utilizo mi nodo backend y lo pongo como apiBasePath: 'http://192.168.1.104:9050'. Luego compilo la aplicación via android-studio. Tanto en el android emulador como en un celular android, siempre me sucede lo mismo.

En la registración del usuario, al guardar los datos del usuario, se intenta guardar y no se guarda. Y se ve este error en el log del studio:

ttp://localhost/main-es2015.js - Line 8770 - Msg: Registering...
E/Capacitor/Console: File: http://localhost/main-es2015.js - Line 8786 - Msg: Error trying to register: {"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"http://192.168.1.104:9050/patients","ok":false,"name":"HttpErrorResponse","message":"Http failure response for http://192.168.1.104:9050/patients: 0 Unknown Error","error":{"isTrusted":true}}

Y del lado node, muestra el error que envié anteriormente.
Si en lugar de usar mi node backend utilizo 'https://coronavirus.yubbuy.com', este error no sucede y la registración funciona.

También vi que dentro del codigo, mas alla de cambiar el apibasepath, hace referencia al this.basePath = 'http://localhost:3000". Eso es correcto? Probe reemplazando todos los 'http://localhost:3000" por mi node y tb tengo ese error.

Desde ya gracias por la ayuda ya que estoy analizando esta app para que sea utilizada por algunos organismos en la argentina. Saludos y gran trabajo

@antonioparraga
Copy link
Collaborator

Sipe, sospecho que android no puede conectar por ser un protocolo no seguro (http://192.168....)
La solución es bien simple:
Añada en el AndroidManifest.xml esto:

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:networkSecurityConfig="@xml/network_security_config" <---- este tío
        android:theme="@style/AppTheme">

y luego cree en .../main/res/xml un fichero llamado network_security_config.xml con este contenido:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

Luego sync + copy android (ionic) y ya está.

El problema es que por defecto no se puede conectar con dominios sin SSL, no es otra cosa.

Ya nos cuenta como le ha ido.

@antonioparraga
Copy link
Collaborator

También puede probar a ponerlo en un protocolo seguro, claro :)

@hggambaro
Copy link
Author

Antonio, muchas gracias. Probé con eso y funcionó perfecto. Muchas gracias por tu ayuda. Si tienes una guía para recomendar para ponerlo en protocolo seguro será bienvenida. Abrazo grande

@antonioparraga
Copy link
Collaborator

Hombre, lo mejor es que pongas el servidor en protocolo seguro. La forma mas cómoda es usar un terminador SSL que haga de proxy y se coma la encriptación mientras tu servidor ni se entera, pero vamos, es una idea.
De todas formas, esto es para desarrollo que se puede hacer el truco este. Para producción creo que no te van a dejar publicar la app si no va contra un servidor con SSL.

@muchemwal
Copy link

@hggambaro i followed your guide and i am still getting the same error on android, the app loads but it wont register a patient.

here is my AndroidManifest.xml

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:networkSecurityConfig="@xml/network_security_config"
        android:theme="@style/AppTheme">

and the network_security_config.xml

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>

ERROR:

E/Capacitor/Console: File: http://192.168.0.100:8100/main.js - Line 10757 - Msg: Error trying to register: {"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"http://localhost:3000/patients","ok":false,"name":"HttpErrorResponse","message":"Http failure response for http://localhost:3000/patients: 0 Unknown Error","error":{"isTrusted":true}}

Please assist

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

No branches or pull requests

3 participants