public void RefreshToken() { var param = "refresh_token=" + Settings.Default.refresh_token; param += "&client_id=" + ClientId + "&client_secret=" + ClientSecret; param += "&grant_type=refresh_token"; var refreshRequest = ImgurAuthorize.ApiOAuthWebRequest("token", param); if (refreshRequest == null) { MessageBox.Show(Resources.ErrorOccuredRefreshing); return; } var responseStream = refreshRequest.GetResponseStream(); if (responseStream != null) { var jsonSerializer = new DataContractJsonSerializer(typeof(ImgurAuthorizationResponse)); var readObject = (ImgurAuthorizationResponse)jsonSerializer.ReadObject(responseStream); SetAuthorizationResponse(readObject); } else { MessageBox.Show(Resources.ErrorOccuredValidating); } }
/// <summary> // If the user's refresh_token is not valid, or if they have not logged in before /// will prompt the user to login to the application by presenting them a new /// authorize window. /// </summary> private void LaunchLogin() { var authorizeUrl = "https://api.imgur.com/oauth2/authorize?client_id=" + ClientId + "&response_type=pin"; Process.Start(authorizeUrl); _authorizeWindow = new ImgurAuthorize(this); _authorizeWindow.ShowDialog(); }