Hi @Dan
The official sample does not provide you with a web view to log in the user. You need to complete the user interaction flow in the browser to obtain the authorization code.
The part of OAuth 2.0 authorization flow is as below:
If you want to get an access token, I recommend you to use the graph SDK. However from my testing MSAL doesn't seem to expose refresh_token to developers, it only refreshes the token for you when your access token expires.
using Microsoft.Identity.Client;
using Microsoft.Graph.Auth;
namespace test1 {
class Program
{
static async System.Threading.Tasks.Task Main(string[] args)
{
string clientId = "{client id}";
string clientSecret = "client secret";
string redirectUri = "redirect url";
string authority = "https://login.microsoftonline.com/{tenant id}";
string authorizationCode = "auth code";
string[] scopes = new string[] { "Mail.Read openid profile email offline_access" };
IConfidentialClientApplication app = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithRedirectUri(redirectUri)
.WithClientSecret(clientSecret)
.WithAuthority(authority)
.Build();
AuthorizationCodeProvider auth = new AuthorizationCodeProvider(app, scopes);
var authResult = await app.AcquireTokenByAuthorizationCode(scopes, authorizationCode).ExecuteAsync();
Console.WriteLine(authResult.AccessToken);
}
};
}
Of course you can use postman to request the /token endpoint to get the refresh token.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.