vedi / restifizer-unity3d

Restifizer SDK for Unity3d
MIT License
62 stars 10 forks source link

Use of "(response) => { }; unclear #2

Closed Niels-NTG closed 9 years ago

Niels-NTG commented 9 years ago

In the ReadMe the following is mentioned:

.Post(parameters, (response) => { // response.Resource - at this point you can use the result });

As somebody who is quite new to this kind of stuff I would like to have a simple example in the ReadMe.md with some real code instead of a comment.

vedi commented 9 years ago

@Niels-NTG, +1 regarding improving the documentation, I hope I'll do this eventually.

It's an example, how we refresh access token (oauth2), I hope it will help:

        RestifizerManager.ResourceAt("oauth").WithClientAuth().Post(parameters, (response) =>
        {
            if (response != null)
            {
                accessToken = response.Resource["access_token"].ToString();
                refreshToken = response.Resource["refresh_token"].ToString();
                RestifizerManager.ConfigBearerAuth(accessToken);  // Configure Restifizer with this token
            }
            else {
                // Something wrong happened
            }
        });