Exemple #1
0
        private static async Task <AppTokenResponse> RedeemRefreshTokenAsync(string clientId, string clientSecret, string refreshToken)
        {
            var queryStringBuilder = new global::OneDrive.QueryStringBuilder();

            queryStringBuilder.Add(Parameters.ClientId, clientId);
            queryStringBuilder.Add(Parameters.ClientSecret, clientSecret);
            queryStringBuilder.Add(Parameters.RedirectUri, LIVE_LOGIN_DESKTOP_URI);
            queryStringBuilder.Add(Parameters.RefreshToken, refreshToken);
            queryStringBuilder.Add(Parameters.GrantType, GrantTypes.RefreshToken);

            var response = await PostQueryAsync(LIVE_LOGIN_TOKEN_URI, queryStringBuilder.ToString());

            return(JsonConvert.DeserializeObject <AppTokenResponse>(response));
        }
Exemple #2
0
        private static Uri GetAuthenticationUri(string clientId)
        {
            var queryStringBuilder = new global::OneDrive.QueryStringBuilder();

            queryStringBuilder.Add(Parameters.ClientId, clientId);
            queryStringBuilder.Add(Parameters.Scope, string.Join(" ", (new [] { Scope.Basic, Scope.OfflineAccess, Scope.Signin, Scope.OneDriveReadWrite }).Select(s => s.GetDescription())));
            queryStringBuilder.Add(Parameters.RedirectUri, LIVE_LOGIN_DESKTOP_URI);
            queryStringBuilder.Add(Parameters.ResponseType, ResponseTypes.Code);
            queryStringBuilder.Add("display", "popup");

            return(new UriBuilder(LIVE_LOGIN_AUTHORIZE_URI)
            {
                Query = queryStringBuilder.ToString()
            }.Uri);
        }