ETrade API authentication could not be completed at this time

I have been trying to get authorized on the ETrade API for a month now using Golang. I have been in contact with their technical support but they are useless. It takes a week for them to respond and sometimes the response is that they are sorry it is taking so long. The latest response just listed the api URLs again.
I have been using these libraries: 

They use Oauth1, so step one is to request a temporary token. Then you use that token to request the next token using a redirect. A couple of times, their website asked for my credentials to allow the app to access my account, but usually it goes right to the error message.
Here is my code:

func GetOauthToken(p *data.DaemonPage, w http.ResponseWriter, req *http.Request) error {
	endpoint := oauth1.Endpoint{
		AuthorizeURL:    AUTHORIZE_URL,
	config := oauth1.Config{
		ConsumerKey:    SANDBOX_API_KEY,
		ConsumerSecret: SANDBOX_API_SECRET,
		CallbackURL:    "oob",
		Endpoint:       endpoint,

	var err, err1 error
	requestToken, requestSecret, err = config.RequestToken()
	if err != nil {
		return err
	fmt.Println(requestToken, requestSecret)

	authorizationURL, err1 := config.AuthorizationURL(requestToken)
	if err1 != nil {
		return err

	values := authorizationURL.Query()

	http.Redirect(w, req, authorizationURL.String(), http.StatusFound)

	return nil

When I do the redirect, I get this message:

Due to a logon delay or other issue, your authentication could not be completed at this time. Please try again.

If anyone can offer suggestions, I would greatly appreciate it.

Hi, Rick, as a disclaimer, I know nothing about OAuth1 or 2 and next to nothing about HTTP, but I’d like to try to help.

Is there a way to dump the entire HTTP request from Postman, where I think you’ve said that this works (headers and the body? I don’t know if HTTP has trailers, but those too, if it has them)? If so, I would recommend copying the definition of the (* method (or the AuthorizationURL method, depending on which one is producing that error you included) out into its own function in your package and add a call (or calls) to net/http/httputil.DumpRequestOut to write the message out to a file so that you can open both Postman’s version of the request(s) and use a diff tool to compare them side-by-side. Maybe that will help identify what (if anything) Postman is doing that Go isn’t, or perhaps something Go is doing that it shouldn’t be?

Actually, it doesn’t work in Postman, either. I tried specifying a callback, which they recommend, but I still get the same error message.
I even tried downloading their Java project for accessing etrade, but it just errors out. It doesn’t even get as far as mine.

I have never been able to resolve this issue, so I have been working on other parts of the project and now I am returning to it.
Yesterday I tried adding both the oauth_consumer_key and the oauth_token to the request header before doing the redirect. I also added the oauth_consumer_key to the URL string.
The current URL string:

This is my code attempting the redirect:

	client := http.Client{
		Transport:     nil,
		CheckRedirect: nil,
		Jar:           nil,
		Timeout:       0,

	OauthClient = oauth.Client{
		Credentials:                   oauth.Credentials{Token: PRODUCTION_API_KEY, Secret: PRODUCTION_API_SECRET},
		TemporaryCredentialRequestURI: PRODUCTION_REQUEST_TOKEN_URL,
		ResourceOwnerAuthorizationURI: AUTHORIZE_URL,
		TokenRequestURI:               ACCESS_TOKEN_URL,
		RenewCredentialRequestURI:     "",
		TemporaryCredentialsMethod:    "",
		TokenCredentailsMethod:        "POST",
		Header:                        nil,
		SignatureMethod:               0,
		PrivateKey:                    nil,

	credentials, err := OauthClient.RequestTemporaryCredentials(&client, "oob", nil)
	if err != nil {
	requestToken = credentials.Token
	requestSecret = credentials.Secret

	authorizationURLString := OauthClient.AuthorizationURL(credentials, nil)
	authorizationURLString += "&oauth_consumer_key=" + PRODUCTION_API_KEY
	req.Header.Set("oauth_consumer_key", PRODUCTION_API_KEY)
	req.Header.Set("oauth_token", requestToken)

	http.Redirect(w, req, authorizationURLString, http.StatusTemporaryRedirect)

One thing I find very strange is that occasionally the redirect seems to work as it requests my eTrade user id and password on my browser as expected. I enter the credentials. It then proceeds to the error message:
Due to a logon delay or other issue, your authentication could not be completed at this time. Please try again.

I tried doing a httputil.DumpRequestOut on the request before redirecting it, but get the error: unsupported protocol scheme “”

Here are the directions from their documentation:

Once your application has the request token, it should redirect the user to an 
E*TRADE authorization page, as shown in the Authorize Application Request URL 
below. Note that this URL includes the request token and the consumer key as 
parameters. Running the URL opens up a page which asks the user to authorize 
the application. Once the user approves the authorization request, E*TRADE 
generates a verification code and displays it the Authorization Complete page. The 
user may then manually copy the code and paste it into the application.

Does anybody have a suggestion on how I can resolve this issue?

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