• 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.2 Latest
Buy Hosting

Permition for Cross domain access

Scheduled Pinned Locked Moved Technical Support
11 Posts 3 Posters 617 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.
  • Mahidul MoonM Offline
    Mahidul MoonM Offline
    Mahidul Moon
    wrote on last edited by PitaJ
    #1

    Hi I am working with nodebb write api plugin ... I can access the get/post request from postman as well but from my another localhost golang application http://127.0.0.1:9004 I can not access the post request. It shows error every time .

    error:

    401 Unauthorized 401 HTTP/1.1 1 1 map[
    Access-Control-Allow-Headers:[Access-Control-Allow-*]
    Connection:[keep-alive]
    Content-Length:[115]
    Content-Security-Policy:[frame-ancestors 'self'] 
    Content-Type:[application/json; charset=utf-8] 
    Date:[Tue, 22 Dec 2020 05:00:55 GMT] 
    Etag:[W/"73-qguwqDaxOp5T4EAjXF5td/L+gH4"] 
    Expect-Ct:[max-age=0] 
    Referrer-Policy:[strict-origin-when-cross-origin] 
    X-Content-Type-Options:[nosniff] 
    X-Dns-Prefetch-Control:[off] 
    X-Download-Options:[noopen] 
    X-Frame-Options:[SAMEORIGIN] 
    X-Permitted-Cross-Domain-Policies:[none] 
    X-Powered-By:[Upskill] 
    X-Xss-Protection:[0]
    ] 0xc000292f00 115 [] false false map[] 0xc000161500 <nil>
    
    PitaJP 1 Reply Last reply
    0
  • PitaJP Offline
    PitaJP Offline
    PitaJ Global Moderator Plugin & Theme Dev
    replied to Mahidul Moon on last edited by
    #2

    @mahidul-moon this is from Golang server code right? Can you share your code and what your request looks like coming out of Golang?

    Mahidul MoonM 1 Reply Last reply
    1
  • julianJ Online
    julianJ Online
    julian GNU/Linux
    wrote on last edited by
    #3

    As @pitaj says, some code example from your end would be helpful.

    A 401 Unauthorized indicates something is wrong with the request (maybe missing or incorrect bearer token)

    Mahidul MoonM 1 Reply Last reply
    0
  • Mahidul MoonM Offline
    Mahidul MoonM Offline
    Mahidul Moon
    replied to julian on last edited by
    #4

    @julian from postman I didn't pass any bearer token same request is passing through golang code

    1 Reply Last reply
    0
  • Mahidul MoonM Offline
    Mahidul MoonM Offline
    Mahidul Moon
    replied to PitaJ on last edited by
    #5

    @pitaj yes of course

    
    			data := map[string]string{"name" : group.Name}
    
    			jsonData,_ := json.Marshal(data)
    
    			url = models.Domain+"/api/v2/groups/"
    			res,err := http.Post(url, "application/json", bytes.NewBuffer(jsonData))
    			if err != nil{
    				fmt.Println(err)
    			}else{
    				fmt.Println(res)
    			}
    
    
    julianJ 1 Reply Last reply
    0
  • julianJ Online
    julianJ Online
    julian GNU/Linux
    replied to Mahidul Moon on last edited by
    #6

    @mahidul-moon you'll have to pass a bearer token in, otherwise it won't know what user to act as

    Mahidul MoonM 2 Replies Last reply
    0
  • Mahidul MoonM Offline
    Mahidul MoonM Offline
    Mahidul Moon
    replied to julian on last edited by
    #7

    @julian ok thanks ... I will try and let's see what happend

    1 Reply Last reply
    0
  • Mahidul MoonM Offline
    Mahidul MoonM Offline
    Mahidul Moon
    replied to julian on last edited by
    #8

    @julian is this a master token ? or just any token generated by user id?

    julianJ 1 Reply Last reply
    0
  • julianJ Online
    julianJ Online
    julian GNU/Linux
    replied to Mahidul Moon on last edited by
    #9

    @mahidul-moon You can generate either a master or a user token, up to you. You can do so from the ACP.

    Mahidul MoonM 1 Reply Last reply
    0
  • Mahidul MoonM Offline
    Mahidul MoonM Offline
    Mahidul Moon
    replied to julian on last edited by
    #10

    @julian but without any bearer token how is it working in postman?

    julianJ 1 Reply Last reply
    0
  • julianJ Online
    julianJ Online
    julian GNU/Linux
    replied to Mahidul Moon on last edited by
    #11

    @mahidul-moon good question, it is because Postman automatically sends the browser cookie if it detects one 🙂

    It's actually really annoying how postman does that...

    1 Reply Last reply
    0

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