I want to access khan academy services, which requires authenticate such as OAuth consumer. Authentication working fine I have used following oauth library.
Steps
Get request token
Now I have a request_token. I need to have it approved by the user.
https://www.khanacademy.org/api/auth2/authorize?oauth_token=t6492705587593216
Khan academy documentation says
When the user clicks the "Accept" button, they will be redirected to callback url specified by oauth_callback
(or /api/auth/default_callback
if a custom callback url is not provided)
https://www.khanacademy.org/api/auth/default_callback?oauth_token_secret=NmZ5nFEttE8gwnnz&oauth_verifier=gyM9xcZVtg&oauth_token=t6492705587593216
Here is my GO Code
const (
CONSUMER_KEY = "XXXXX"
CONSUMER_SECRET = "XXXXXXXX"
)
func GetRequestToken(r *http.Request,unitAttemptID int64)(string,error){
c := oauth.NewConsumer(
CONSUMER_KEY,
CONSUMER_SECRET,
oauth.ServiceProvider{
RequestTokenUrl: "https://www.khanacademy.org/api/auth2/request_token",
AuthorizeTokenUrl: "https://www.khanacademy.org/api/auth2/authorize",
AccessTokenUrl: "https://www.khanacademy.org/api/auth2/access_token",
ExerciseUrl: "https://www.khanacademy.org/api/v1/user/exercises",
})
callback := "http://127.0.0.1/example/index.php/khan/authorizeRequestToken"
requestToken, u, err := c.GetRequestTokenAndUrl(callback)
if err != nil {
fmt.Println("err is - ",err)
return "",err
}
fmt.Println("requestToken ",requestToken)
return u,nil
}
Problem
It always redirect me on custom default URL. I want to redirect my own callback url.