• Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
v3.5.1 Latest
Buy Hosting

Can't make api/user work with a token

Scheduled Pinned Locked Moved Solved Technical Support
2 Posts 1 Posters 325 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fred
    wrote on last edited by
    #1

    Hello,
    I'm trying to get my users by email in my project.
    But i can't access to the api/user fonctionnality.

    I created a token for the user _uid = 1, the admin of the forum in : /admin/settings/api.
    When i try the "unread" and the "users" fonctionnalities, all works fine but on "user", my request is not authorized.

    There is my test commands :

    curl https://lestribunes-dev.unitedmanagers.com/api/unread -H "Authorization: Bearer 5dfa7696-a8dd-4e6b-8806-2afba838ab12" => WORKS !

    curl https://lestribunes-dev.unitedmanagers.com/api/users -H "Authorization: Bearer 5dfa7696-a8dd-4e6b-8806-2afba838ab12" => WORKS !

    curl https://lestribunes-dev.unitedmanagers.com/api/user/uid/10300 -H "Authorization: Bearer 5dfa7696-a8dd-4e6b-8806-2afba838ab12" => "status":{"code":"not-authorised","message":"Aucune session de connexion valide trouvée. Veuillez vous connecter et réessayer."}

    curl https://lestribunes-dev.unitedmanagers.com/api/user/email/[email protected] -H "Authorization: Bearer 5dfa7696-a8dd-4e6b-8806-2afba838ab12" => {"status":{"code":"not-authorised","message":"Aucune session de connexion valide trouvée. Veuillez vous connecter et réessayer."}

    If someone have an idea how resolve this, please let me know.
    Thanks in advance.

    1 Reply Last reply
    0
  • F Offline
    F Offline
    Fred
    wrote on last edited by
    #2

    Well i found a solution with the users query :

    const axiosInstanceForNativeAPI = axios.create({
      baseURL: ENDPOINT_URL,
      headers: {
        Authorization: ADMIN_TOKEN_FOR_NATIVE_API
      },
    });
    
    export const getUserByEmail = email => axiosInstanceForNativeAPI.get(`/users?searchBy=email&query=${email}`);
    
    export const getUserByUsername = username => axiosInstanceForNativeAPI.get(`/users?searchBy=username&query=${username}`);
    
    1 Reply Last reply
    0
  • F Fred has marked this topic as solved on

Copyright © 2023 NodeBB | Contributors
  • Login

  • Don't have an account? Register

  • Login or register to search.
Powered by NodeBB Contributors
  • First post
    Last post
0
  • Home
  • Categories
  • Recent
  • Popular
  • Top
  • Tags
  • Users
  • Groups
  • Documentation
    • Home
    • Read API
    • Write API
    • Plugin Development