Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 05d2416

Browse files
authored
Merge pull request #20 from kgamecarter/master
Fix OneDriveGraphApi when use custom redirect url error.
2 parents cb6cc90 + 1ce049f commit 05d2416

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Api/OneDriveGraphApi.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public class OneDriveGraphApi : OneDriveApi
6767
/// Instantiates a new instance of the Graph API
6868
/// </summary>
6969
/// <param name="applicationId">Microsoft Application ID to use to connect</param>
70-
public OneDriveGraphApi(string applicationId) : base(applicationId, null)
70+
/// <param name="clientSecret">Microsoft Application secret to use to connect</param>
71+
public OneDriveGraphApi(string applicationId, string clientSecret = null) : base(applicationId, clientSecret)
7172
{
7273
OneDriveApiBaseUrl = GraphApiBaseUrl + "me/";
7374
}
@@ -112,6 +113,8 @@ protected async Task<OneDriveAccessToken> GetAccessTokenFromAuthorizationToken(s
112113
queryBuilder.Add("code", authorizationToken);
113114
queryBuilder.Add("redirect_uri", AuthenticationRedirectUrl);
114115
queryBuilder.Add("grant_type", "authorization_code");
116+
if (ClientSecret != null)
117+
queryBuilder.Add("client_secret", ClientSecret);
115118
return await PostToTokenEndPoint(queryBuilder);
116119
}
117120

@@ -142,6 +145,8 @@ protected async Task<OneDriveAccessToken> GetAccessTokenFromRefreshToken(string
142145
queryBuilder.Add("refresh_token", refreshToken);
143146
queryBuilder.Add("redirect_uri", AuthenticationRedirectUrl);
144147
queryBuilder.Add("grant_type", "refresh_token");
148+
if (ClientSecret != null)
149+
queryBuilder.Add("client_secret", ClientSecret);
145150
return await PostToTokenEndPoint(queryBuilder);
146151
}
147152

0 commit comments

Comments
 (0)