I am writing a command line tool for accessing Medium.com's API using Go. They have released this SDK for golang too.
I have followed the instructions until the point where I can build a url using secret state, redirect url, and scopes.
package main
import (
"fmt"
"net/http"
"github.com/Medium/medium-sdk-go"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func mediumAuth() {
m := medium.NewClient("clientIDString", "clientSecretString")
url := m.GetAuthorizationURL("supersecretstring", "http://hasit.me/callback/medium", medium.ScopeBasicProfile, medium.ScopePublishPost)
//next step
}
func main() {
mediumAuth()
}
The next step is to open the url to let user give permission for accessing his/her profile. I can successfully open the url.
exec.Command("open", url).Start()
Now, once the user clicks on the url, how can I fetch the redirected url? I even tried using http GET but the response is not the one that I want.
resp, err := http.Get(url)
I am sorry if the answer is obvious but this will be my first program where I use some API in any language. Help will be appreciated.