Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WNS: Authentication token gets renewed only once #691

Open
es-alt opened this issue Apr 20, 2016 · 0 comments
Open

WNS: Authentication token gets renewed only once #691

es-alt opened this issue Apr 20, 2016 · 0 comments

Comments

@es-alt
Copy link

es-alt commented Apr 20, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant