Skip to content

WNS: Authentication token gets renewed only once #691

Open
@es-alt

Description

@es-alt

What version of PushSharp are you using?

4.0.4

Describe your issue:

I have WNS broker running in process in the cloud. The broker is instantiated only once when the azure role starts and it runs uninterrupted for days. When a WNS authentication token expires, WnsAccessTokenManager will try to updated it only once.

Look at the code:

` Task renewAccessTokenTask = null;
string accessToken = null;
HttpClient http;

    public WnsAccessTokenManager (WnsConfiguration configuration)
    {
        http = new HttpClient ();
        Configuration = configuration;
    }

    public WnsConfiguration Configuration { get; private set; }

    public async Task<string> GetAccessToken ()
    {
        if (accessToken == null) {
            if (renewAccessTokenTask == null) {
                Log.Info ("Renewing Access Token");
                renewAccessTokenTask = RenewAccessToken ();
                await renewAccessTokenTask;
            } else {
                Log.Info ("Waiting for access token");
                await renewAccessTokenTask;
            }
        }

        return accessToken;
    }`

"renewAccessTokenTask " will be null only for the first time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions