Get sharepoint access token package to access SHAREPOINT REST API.
A Flutter sharepoint_auth package for performing authentication to retrieve access token for accessing SHAREPOINT REST API by using OAuth2 v2.0 endpoint. Forked from Earlybyte.aad_oauth AAD Package.
For using this library you have to create an azure app at the Azure App registration portal. Use native app as plattform type.
Register App on Sharepoint Site by using : https://YourDomainName.SharePoint.com/sites/YourSiteName/_layouts/15/appregnew.aspx
Afterwards you have to initialize the library as follow:
final SharepointConfig config = new SharepointConfig(
"Sharepoint Client Id",
"Sharepoint Client Secret",
"Sharepoint Resource",
"Sharepoint Site",
"Your Tenant Id",);
final Sharepointauth sharepointauth = new Sharepointauth(config);
This allows you to pass in Client Id, Client Secret, Sharepoint Resource, Sharepoint Site and Tenant Id.
Then once you have an Sharepointauth instance, you can call login()
and afterwards getAccessToken()
to retrieve an access token:
await sharepointauth.login();
String accessToken = await sharepointauth.getAccessToken();
You can also call getAccessToken()
directly. It will automatically login and retrive an access token.
Tokens are cached in memory. to destroy the tokens you can call logout()
:
Tokens have expire offset of 1800 secs
:
await sharepointauth.logout();
Add the following to your pubspec.yaml dependencies:
dependencies:
sharepoint_auth: "^0.1.0"
If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕
The source code is 100% Dart, and everything resides in the /lib folder.
If you found this project useful, then please consider giving it a ⭐ on Github and sharing it.
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -m 'Added some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
Copyright 2019 Shail Patel
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
For help getting started with Flutter, view our online documentation.
For help on editing package code, view the documentation.