How to handle 302 redirection in golang


(Yogesh Bodke) #1

Hi Guys,

I am new to Golang. I have just started working on my first GoLang project. A short overview of the requirements which I am implementing in Go.

  1. A client will send an authorization request to API server. For example, http://api.xyz.com/v1/authorize?apiKey=“key”&redirect=“URL”
  2. After submitting above request the server redirecting to the login page - http://api.xyz.com/login
  3. Here user will log in using their credential and after validation, he will get an Access Code in URL query parms.

Please help :slight_smile:

=====================
UPDATE

I am able to get the redirect location but how can I maintain a session and do a POST on the login page. Example request body:

{
  "username": "joe"
  "password": "xxxxxxxx"
}

(Kristoffer Berdal) #2

Take a look at this https://gowebexamples.com/sessions/ for examples on how to use sessions in Go.


(system) #4

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.