HMS-Core/hms-push-serverdemo-go

Refresh token is not work

Opened this issue · 3 comments

Access token after refresh token is not replace on http request for send push notification.
HTTP request still use previous access token.

Which method do you use to refresh token? Please check whether this error is reported when you refresh token.

on executeApiOperation method: src/push/core/pushclient.go

when access token expried.
isNeedRetry method get new access token but Authorization access token in request.Header is not change.

Maybe change on sendHttpRequest method: src/push/core/pushclient.go for fix it.


func (c *HttpPushClient) sendHttpRequest(ctx context.Context, request *httpclient.PushRequest, responsePointer interface{}) error {
	request.Header = []httpclient.HTTPOption{
		httpclient.SetHeader("Content-Type", "application/json;charset=utf-8"),
		httpclient.SetHeader("Authorization", "Bearer "+c.token),
	}

	resp, err := c.client.DoHttpRequest(ctx, request)
	if err != nil {
		return err
	}

	if err = json.Unmarshal(resp.Body, responsePointer); err != nil {
		return err
	}
	return nil
}

This issue has been solved in the latest commit, please refer to afaab2f