App-wsgetmail
view release on metacpan or search on metacpan
# CONFIGURATION
## Configuring Microsoft 365 Client Access
To use wsgetmail, first you need to set up the app in Microsoft 365.
Two authentication methods are supported:
- Client Credentials
This method uses shared secrets and is preferred by Microsoft.
(See [Client credentials](https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#client-credentials))
- Username/password
This method is more like previous connections via IMAP. It is currently
supported by Microsoft, but not recommended. (See [Username/password](https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#usernamepassword))
This section walks you through each piece of configuration wsgetmail needs,
and how to obtain it.
- tenant\_id
need to run it multiple times with different configuration.
If you only need to change a couple small configuration settings like the
folder name, you can use the `--options` argument to override those from a
base configuration file. For example:
wsgetmail --config=wsgetmail.json --options='{"folder": "Inbox"}'
wsgetmail --config=wsgetmail.json --options='{"folder": "Other Folder"}'
NOTE: Setting `secret` or `user_password` with `--options` is not secure
and may expose your credentials to other users on the local system. If you
need to set these options, or just change a lot of settings in your
configuration, just run wsgetmail with different configurations:
wsgetmail --config=account01.json
wsgetmail --config=account02.json
## Office 365 API Limits
Microsoft applies some limits to the amount of API requests allowed as
documented in their [Microsoft Graph throttling guidance](https://docs.microsoft.com/en-us/graph/throttling).
lib/App/wsgetmail.pm view on Meta::CPAN
=head2 Configuring Microsoft 365 Client Access
To use wsgetmail, first you need to set up the app in Microsoft 365.
Two authentication methods are supported:
=over
=item Client Credentials
This method uses shared secrets and is preferred by Microsoft.
(See L<Client credentials|https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#client-credentials>)
=item Username/password
This method is more like previous connections via IMAP. It is currently
supported by Microsoft, but not recommended. (See L<Username/password|https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#usernamepassword>)
=back
This section walks you through each piece of configuration wsgetmail needs,
and how to obtain it.
lib/App/wsgetmail.pm view on Meta::CPAN
need to run it multiple times with different configuration.
If you only need to change a couple small configuration settings like the
folder name, you can use the C<--options> argument to override those from a
base configuration file. For example:
wsgetmail --config=wsgetmail.json --options='{"folder": "Inbox"}'
wsgetmail --config=wsgetmail.json --options='{"folder": "Other Folder"}'
NOTE: Setting C<secret> or C<user_password> with C<--options> is not secure
and may expose your credentials to other users on the local system. If you
need to set these options, or just change a lot of settings in your
configuration, just run wsgetmail with different configurations:
wsgetmail --config=account01.json
wsgetmail --config=account02.json
=head2 Office 365 API Limits
Microsoft applies some limits to the amount of API requests allowed as
documented in their L<Microsoft Graph throttling guidance|https://docs.microsoft.com/en-us/graph/throttling>.
lib/App/wsgetmail/MS365/Client.pm view on Meta::CPAN
is => 'rw',
default => sub { return 0 }
);
has _ua => (
builder => '_build_authorised_ua',
is => 'ro',
lazy => 1,
);
has _credentials => (
is => 'ro',
lazy => 1,
builder => '_build__credentials',
);
has _access_token => (
is => 'ro',
lazy => 1,
builder => '_build__access_token',
);
sub BUILD {
my ($self, $args) = @_;
lib/App/wsgetmail/MS365/Client.pm view on Meta::CPAN
my $ua = $self->_new_useragent;
warn "getting system access token" if ($self->debug);
$ua->default_header( Authorization => $self->_access_token() );
return $ua;
}
sub _build__access_token {
my $self = shift;
my $access_token;
if ($self->global_access) {
$access_token = $self->_credentials->access_token;
}
else {
$access_token = $self->_get_user_access_token;
}
return $access_token;
}
sub _get_user_access_token {
my $self = shift;
my $ua = $self->_new_useragent;
lib/App/wsgetmail/MS365/Client.pm view on Meta::CPAN
$access_token = "Bearer " . $token_details->{access_token};
}
else {
# throw error
warn "auth response from server : $raw_message" if ($self->debug);
die sprintf('unable to get user access token for user %s request failed with status %s ', $self->username, $response->status_line);
}
return $access_token;
}
sub _build__credentials {
my $self = shift;
my $creds = Azure::AD::ClientCredentials->new(
resource_id => $self->resource_url,
client_id => $self->client_id,
secret_id => $self->secret,
tenant_id => $self->tenant_id
);
return $creds;
}
( run in 0.285 second using v1.01-cache-2.11-cpan-a5abf4f5562 )