Repository: Clancey/SimpleAuth Branch: main Commit: 4317c3a53e66 Files: 233 Total size: 2.1 MB Directory structure: gitextract_9s2872fj/ ├── .github/ │ └── workflows/ │ └── mainPackage.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SimpleAuth.Droid.CustomTabs.nuspec ├── SimpleAuth.Facebook.Droid.nuspec ├── SimpleAuth.Facebook.iOS.nuspec ├── SimpleAuth.Google.Droid.nuspec ├── SimpleAuth.Google.iOS.nuspec ├── SimpleAuth.nuspec ├── samples/ │ ├── .nuget/ │ │ └── NuGet.Config │ ├── Sample.Droid/ │ │ ├── Assets/ │ │ │ └── AboutAssets.txt │ │ ├── MainActivity.cs │ │ ├── Properties/ │ │ │ ├── AndroidManifest.xml │ │ │ └── AssemblyInfo.cs │ │ ├── Resources/ │ │ │ ├── AboutResources.txt │ │ │ ├── Resource.Designer.cs │ │ │ ├── layout/ │ │ │ │ └── Main.axml │ │ │ └── values/ │ │ │ └── Strings.xml │ │ └── Sample.Droid.csproj │ ├── Sample.Forms/ │ │ ├── Sample.Forms/ │ │ │ ├── App.cs │ │ │ ├── LoginPage.xaml │ │ │ ├── LoginPage.xaml.cs │ │ │ ├── Sample.Forms.projitems │ │ │ └── Sample.Forms.shproj │ │ ├── Sample.Forms.Droid/ │ │ │ ├── Assets/ │ │ │ │ └── AboutAssets.txt │ │ │ ├── MainActivity.cs │ │ │ ├── Properties/ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── AssemblyInfo.cs │ │ │ ├── Resources/ │ │ │ │ ├── AboutResources.txt │ │ │ │ └── Resource.Designer.cs │ │ │ ├── Sample.Forms.Droid.csproj │ │ │ └── SimpleAuth.keystore │ │ ├── Sample.Forms.UWP/ │ │ │ ├── App.xaml │ │ │ ├── App.xaml.cs │ │ │ ├── MainPage.xaml │ │ │ ├── MainPage.xaml.cs │ │ │ ├── Package.appxmanifest │ │ │ ├── Properties/ │ │ │ │ ├── AssemblyInfo.cs │ │ │ │ └── Default.rd.xml │ │ │ ├── Sample.Forms.UWP.csproj │ │ │ ├── Sample.Forms.UWP.nuget.props │ │ │ └── Sample.Forms.UWP.nuget.targets │ │ ├── Sample.Forms.WinPhone/ │ │ │ ├── App.xaml │ │ │ ├── App.xaml.cs │ │ │ ├── MainPage.xaml │ │ │ ├── MainPage.xaml.cs │ │ │ ├── Package.appxmanifest │ │ │ ├── Properties/ │ │ │ │ └── AssemblyInfo.cs │ │ │ ├── Sample.Forms.WinPhone.csproj │ │ │ └── packages.config │ │ ├── Sample.Forms.Windows/ │ │ │ ├── App.xaml │ │ │ ├── App.xaml.cs │ │ │ ├── MainPage.xaml │ │ │ ├── MainPage.xaml.cs │ │ │ ├── Package.appxmanifest │ │ │ ├── Properties/ │ │ │ │ └── AssemblyInfo.cs │ │ │ ├── Sample.Forms.Windows.csproj │ │ │ └── packages.config │ │ └── Sample.Forms.iOS/ │ │ ├── AppDelegate.cs │ │ ├── Entitlements.plist │ │ ├── Info.plist │ │ ├── Main.cs │ │ ├── Properties/ │ │ │ └── AssemblyInfo.cs │ │ ├── Resources/ │ │ │ └── LaunchScreen.storyboard │ │ ├── Sample.Forms.iOS.csproj │ │ ├── iTunesArtwork │ │ └── iTunesArtwork@2x │ ├── Sample.Mac/ │ │ ├── AppDelegate.cs │ │ ├── AppDelegate.designer.cs │ │ ├── Entitlements.plist │ │ ├── Info.plist │ │ ├── Main.cs │ │ ├── MainMenu.xib │ │ ├── MainWindow.cs │ │ ├── MainWindow.designer.cs │ │ ├── MainWindow.xib │ │ ├── MainWindowController.cs │ │ ├── MainWindowController.designer.cs │ │ ├── Resources/ │ │ │ └── Images.xcassets/ │ │ │ └── AppIcons.appiconset/ │ │ │ └── Contents.json │ │ └── Sample.Mac.csproj │ ├── Sample.Maui/ │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── LoginPage.xaml │ │ ├── LoginPage.xaml.cs │ │ ├── MauiProgram.cs │ │ ├── Platforms/ │ │ │ ├── Android/ │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── MainActivity.cs │ │ │ │ ├── MainApplication.cs │ │ │ │ └── Resources/ │ │ │ │ └── values/ │ │ │ │ └── colors.xml │ │ │ ├── MacCatalyst/ │ │ │ │ ├── AppDelegate.cs │ │ │ │ ├── Info.plist │ │ │ │ └── Program.cs │ │ │ ├── Windows/ │ │ │ │ ├── App.xaml │ │ │ │ ├── App.xaml.cs │ │ │ │ ├── Package.appxmanifest │ │ │ │ └── app.manifest │ │ │ └── iOS/ │ │ │ ├── AppDelegate.cs │ │ │ ├── Info.plist │ │ │ └── Program.cs │ │ ├── Properties/ │ │ │ └── launchSettings.json │ │ ├── Resources/ │ │ │ ├── Raw/ │ │ │ │ └── AboutAssets.txt │ │ │ └── Styles/ │ │ │ ├── Colors.xaml │ │ │ └── Styles.xaml │ │ └── Sample.Maui.csproj │ ├── Sample.iOS/ │ │ ├── AppDelegate.cs │ │ ├── Entitlements.plist │ │ ├── Info.plist │ │ ├── Main.cs │ │ ├── Properties/ │ │ │ └── AssemblyInfo.cs │ │ ├── Resources/ │ │ │ └── LaunchScreen.xib │ │ ├── Sample.iOS.csproj │ │ └── Spinner.cs │ ├── SimpleAuth.Samples.Windows.sln │ └── SimpleAuth.Samples.sln └── src/ ├── .nuget/ │ └── NuGet.Config ├── SimpleAuth/ │ ├── Api/ │ │ ├── Account.cs │ │ ├── Api.cs │ │ ├── ApiResponse.cs │ │ ├── Attributes.cs │ │ ├── AuthenticatedApi.cs │ │ ├── Authenticator.cs │ │ ├── JSonExtensions.cs │ │ └── WebAuthenticator.cs │ ├── ApiKey/ │ │ ├── ApiKeyApi.cs │ │ └── AuthLocation.cs │ ├── BasicAuth/ │ │ ├── BasicAuthAccount.cs │ │ ├── BasicAuthApi.cs │ │ ├── BasicAuthAuthenticator.cs │ │ └── IBasicAuthenicator.cs │ ├── Converters/ │ │ ├── Converter.cs │ │ └── JsonConverter.cs │ ├── Helpers/ │ │ ├── CookieHolder.cs │ │ ├── IAuthStorage.cs │ │ ├── Resolver.cs │ │ └── UrlUtility.cs │ ├── OAuth/ │ │ ├── OAuthAccount.cs │ │ ├── OAuthApi.cs │ │ ├── OAuthAuthenticator.cs │ │ ├── OAuthPasswordApi.cs │ │ ├── OauthApiKeyApi.cs │ │ └── OauthResponse.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ ├── Providers/ │ │ ├── ADFS.cs │ │ ├── Amazon.cs │ │ ├── AzureB2CApi.cs │ │ ├── DropBox.cs │ │ ├── Facebook.cs │ │ ├── FitBitApi.cs │ │ ├── Github.cs │ │ ├── Google.cs │ │ ├── Instagram.cs │ │ ├── LinkedIn.cs │ │ ├── MicrosoftLiveConnectApi.cs │ │ └── Twitter.cs │ ├── SimpleAuth.projitems │ └── SimpleAuth.shproj ├── SimpleAuth.Droid/ │ ├── ActivityStateRepository.cs │ ├── App.config │ ├── AuthStorage.cs │ ├── LoginActvity.cs │ ├── Native.cs │ ├── Resources/ │ │ ├── AboutResources.txt │ │ ├── Resource.Designer.cs │ │ ├── Values/ │ │ │ └── Strings.xml │ │ └── layout/ │ │ └── login.axml │ ├── SimpleAuth.Droid.csproj │ ├── TypeForwarded.cs │ └── WebAuthenticatorActivity.cs ├── SimpleAuth.Droid.CustomTabs/ │ ├── ActivityLifecycleCallbackManager.cs │ ├── NativeCustomTabsAuthenticator.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ ├── Resources/ │ │ ├── AboutResources.txt │ │ └── Resource.Designer.cs │ ├── SimpleAuth.Droid.CustomTabs.csproj │ └── SimpleAuthCallbackActivity.cs ├── SimpleAuth.Facebook.Droid/ │ ├── ActivityLifecycleManager.cs │ ├── Facebook.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ ├── Resources/ │ │ ├── AboutResources.txt │ │ ├── Resource.designer.cs │ │ └── values/ │ │ └── Strings.xml │ └── SimpleAuth.Facebook.Droid.csproj ├── SimpleAuth.Facebook.iOS/ │ ├── Facebook.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ └── SimpleAuth.Facebook.iOS.csproj ├── SimpleAuth.Google.Droid/ │ ├── ActivityLifecycleManager.cs │ ├── Google.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ ├── Resources/ │ │ ├── AboutResources.txt │ │ ├── Resource.designer.cs │ │ └── values/ │ │ └── Strings.xml │ └── SimpleAuth.Google.Droid.csproj ├── SimpleAuth.Google.iOS/ │ ├── Google.cs │ ├── Properties/ │ │ └── AssemblyInfo.cs │ └── SimpleAuth.Google.iOS.csproj ├── SimpleAuth.Mac/ │ ├── AppleEventsHelper.cs │ ├── AuthStorage.cs │ ├── Entitlements.plist │ ├── Native.cs │ ├── NativeSafariAuthenticator.cs │ ├── SimpleAuth.Mac.csproj │ └── WebAuthenticator.cs ├── SimpleAuth.Mac.sln ├── SimpleAuth.Net/ │ ├── AuthStorage.cs │ └── SimpleAuth.Net.csproj ├── SimpleAuth.Net6/ │ └── SimpleAuth-net6.csproj ├── SimpleAuth.Tests/ │ ├── Helpers/ │ │ ├── FakeHttpHandler.cs │ │ ├── InMemoryAuthStorage.cs │ │ └── RequestMessage.cs │ ├── OAuth/ │ │ ├── OAuthApiTests.cs │ │ ├── OAuthData.cs │ │ └── OAuthTestApi.cs │ └── SimpleAuth.Tests.csproj ├── SimpleAuth.UWP/ │ ├── AuthStorage.cs │ ├── CustomWebAuthenticationBroker.cs │ ├── CustomWebAuthenticationResult.cs │ ├── SimpleAuth.UWP.csproj │ ├── SimpleAuth.UWP.nuget.props │ └── WebAuthenticatorWebView.cs ├── SimpleAuth.iOS/ │ ├── App.config │ ├── AuthStorage.cs │ ├── BasicAuthController.cs │ ├── Entitlements.plist │ ├── Native.cs │ ├── NativeSafariAuthenticator.cs │ ├── SimpleAuth.iOS.csproj │ ├── Twitter.cs │ ├── TypeForwarded.cs │ ├── WebAuthenticatorViewController.cs │ └── WebAuthenticatorWindow.cs └── SimpleAuth.sln ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/mainPackage.yml ================================================ name: .NET on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: name: Build SimpleAuth Nuget env: NUPKG_MAJOR: 0.2 BASE: 334 NUPKG_SUFFIX: -alpha runs-on: windows-latest steps: - uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 6.0.x - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.1 with: vs-prerelease: true - name: Install Maui Workload shell: pwsh run: | & dotnet workload install maui ` --skip-sign-check ` - name: install Xamarin shell: pwsh run: | dotnet tool install --global boots boots --stable Xamarin.iOS boots --stable Xamarin.Mac - name: Build run: msbuild /r src/SimpleAuth.sln - name: Nuget Pack step shell: bash run: | MINOR_VERSION=$(( $BASE + $GITHUB_RUN_NUMBER )) VERSION=$NUPKG_MAJOR.$MINOR_VERSION$NUPKG_SUFFIX echo "PACKAGE VERSION: $VERSION" nuget pack SimpleAuth.nuspec -version $VERSION -Symbols -SymbolPackageFormat snupkg - uses: actions/upload-artifact@v2 name: Upload Nuget Artifact with: name: nuget-artifact.${{env.GITHUB_RUN_NUMBER}} path: | **\*.nupkg **\*.snupkg **\*.symbols.nupkg ================================================ FILE: .gitignore ================================================ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. .droidres [Cc]omponents/ # User-specific files *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ build/ bld/ [Bb]in/ [Oo]bj/ # Visual Studo 2015 cache/options directory .vs/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUNIT *.VisualState.xml TestResult.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c *_i.c *_p.c *_i.h *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opensdf *.sdf *.cachefile # Visual Studio profiler *.psess *.vsp *.vspx # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # JustCode is a .NET coding addin-in .JustCode # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # NCrunch _NCrunch_* .*crunch*.local.xml # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # TODO: Comment the next line if you want to checkin your web deploy settings # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore **/packages/* [Cc]omponents # except build/, which is used as an MSBuild target. !**/packages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/packages/repositories.config # Windows Azure Build Output csx/ *.build.csdef # Windows Store app package directory AppPackages/ # Others *.[Cc]ache ClientBin/ [Ss]tyle[Cc]op.* ~$* *~ *.dbmdl *.dbproj.schemaview *.pfx *.publishsettings node_modules/ bower_components/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm # SQL Server files *.mdf *.ldf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings # Microsoft Fakes FakesAssemblies/ # Node.js Tools for Visual Studio .ntvs_analysis.dat # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Universal Windows Platform project.lock.json .DS_Store *.bak *.bak .idea ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at james.clancey@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} 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. ================================================ FILE: README.md ================================================ # Simple Auth Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authentication into the API so you dont need to deal with it. Most importantly it works great with traditional Xamarin and Xamarin.Forms [![Join the chat at https://gitter.im/simpleauth/community](https://badges.gitter.im/simpleauth/community.svg)](https://gitter.im/simpleauth/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Android: [![Android Build status](https://build.appcenter.ms/v0.1/apps/7e5acfa7-b0fb-4468-8e0a-f947abcded95/branches/master/badge)](https://appcenter.ms) iOS/MacOS: [![Build status](https://build.appcenter.ms/v0.1/apps/fabfc2aa-5ed3-420b-b257-343b158c176e/branches/master/badge)](https://appcenter.ms) # General information ## Available on Nuget [Clancey.SimpleAuth](https://www.nuget.org/packages/Clancey.SimpleAuth/) ## Providers ### Current Built in Providers * Azure Active Directory * Amazon * Dropbox * Facebook * Github * Google * Instagram * Linked In * Microsoft Live Connect * Twitter Simple auth ships with some built in providers so you just need to add your keys and scopes. ```cs var scopes = new[] { "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile" }; var api = new GoogleApi("google", "clientid", "clientsecret") { Scopes = scopes, }; var account = await api.Authenticate(); ``` ## Restful Api Requests Restful Api Requests couldnt be simpler ```cs var song = await api.Get("http://myapi/Song/",songId); ``` Paramaters can be added as part of the path ```cs var todoItem = await api.Get("http://myapi/user/{UserId}/TodoItem",new Dictionary{["UserId"] = "1", ["itemID"] = "22"}); ``` Generates the following Url: ```cs http://myapi/user/1/TodoItem?itemID=22 ``` ## Attribute your Api Requests (Optional) ```cs [Path("/pet")] [ContentType("application/json")] [Accepts("application/json")] public virtual Task AddPet(Pet body) { return Post( body); } ``` # iOS/Mac Specific ## OnePassword Support (iOS) One password support is for iOS Only. Simply add the project or the Nuget [Clancey.SimpleAuth.OnePassword](https://www.nuget.org/packages/Clancey.SimpleAuth.OnePassword/) Then call the following line in your iOS project prior to calling api.Authenticate(); ```cs SimpleAuth.OnePassword.Activate(); ``` ## Native Twitter Support via Twitter App You can use the Twitter app to authenticate with SimpleAuth on iOS. Add the following to your Info.Plist ``` // Info.plist CFBundleURLTypes CFBundleURLSchemes twitterkit- LSApplicationQueriesSchemes twitter twitterauth ``` Then call the following line in your iOS AppDelegate FinishedLaunching method; ```cs SimpleAuth.Providers.Twitter.Init(); ``` Also add the following override in your AppDelegate ```cs public override bool OpenUrl (UIApplication app, NSUrl url, NSDictionary options) { if (SimpleAuth.Native.OpenUrl(app, url, options)) return true; return base.OpenUrl(app,url,options); } ``` ## Native Facebook Support via iOS SDK Simply add the project or the Nuget [Clancey.SimpleAuth.Facebook.iOS](https://www.nuget.org/packages/Clancey.SimpleAuth.Facebook.iOS/) The Facebook SDK requires you modify your info.plist : https://components.xamarin.com/gettingstarted/facebookios Then call the following line in your iOS AppDelegate FinishedLaunching method; ```cs SimpleAuth.Providers.Facebook.Init(app, options); ``` Also add the following override in your AppDelegate ```cs public override bool OpenUrl (UIApplication app, NSUrl url, NSDictionary options) { if (SimpleAuth.Native.OpenUrl(app, url, options)) return true; return base.OpenUrl(app,url,options); } ``` ## Native Google Support via iOS SDK [Clancey.SimpleAuth.Google.iOS](https://www.nuget.org/packages/Clancey.SimpleAuth.Google.iOS/) The Google SDK can do Cross-Client Login. This allows you to get tokens for the server, with one login. To use Cross-client you need to set the ServerClientId on the GoogleApi. Call the following in your FinishedLaunching Method; ```cs SimpleAuth.Providers.Google.Init() ``` Also add the following to your AppDelegate ```cs public override bool OpenUrl (UIApplication app, NSUrl url, NSDictionary options) { if (SimpleAuth.Native.OpenUrl(app, url, options)) return true; return base.OpenUrl(app,url,options); } ``` If you need Cross-client authentication ```cs var api = new GoogleApi("google","client_id"){ ServerClientId = "server_client_id"" }; var account = await api.Authenticate (); var serverToken = account.UserData ["ServerToken"]; ``` ### Troubleshooting ``` System.Exception: Error Domain=com.google.GIDSignIn Code=-2 "keychain error" UserInfo={NSLocalizedDescription=keychain error} ``` Under the iOS Build Signing, Custom Entitlements: make sure an entitlement.plist is set ## Native SFSafariViewController iOS/MacOS SFSafariViewController Allows users to use Safari to login, instead of embedded webviews. Google now requires this mode and is enabled by default for Google Authentication on iOS/MacOS. To use the Native Safari Authenticator, you are required to add the following snippet in your AppDelegate (**iOS Only**) ```cs public override bool OpenUrl (UIApplication app, NSUrl url, NSDictionary options) { if (SimpleAuth.Native.OpenUrl(app, url, options)) return true; return base.OpenUrl(app,url,options); } ``` You are also required to add the following to add a CFBundleURLSchemes to your info.plist For Google: com.googleusercontent.apps.YOUR_CLIENT_ID ``` CFBundleURLTypes CFBundleURLSchemes com.googleusercontent.apps.YOURCLIENTID CFBundleURLName googleLogin ``` # Android ## Google Sign-In on Android Simple Auth supports the native Google Sign-in for Android. 1. Add the nuget [Clancey.SimpleAuth.Google.Droid](https://www.nuget.org/packages/Clancey.SimpleAuth.Google.Droid/) 2. Create OAuth Client Id (Web Application): [Link](https://console.developers.google.com/apis/credentials) 3. Create and OAuth Android app: [Link](https://console.developers.google.com/apis/credentials) * Sign your app using the same Keystore 4. Use both the Web Application ClientID. ClientSecret is not required but reccomended. 5. Add the following code to your Main Activity ```cs protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SimpleAuth.Providers.Google.Init(this.Application); //The rest of your initialize code } protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); SimpleAuth.Native.OnActivityResult (requestCode,resultCode,data); } ``` If you need Cross-Client authentication pass your ServerClientId into the google api ```cs var api = new GoogleApi("google","client_id"){ ServerClientId = "server_client_id"" }; var account = await api.Authenticate (); var serverToken = account.UserData ["ServerToken"]; ``` ### Troubleshooting If you get: ```Unable to find explicit activity class {com.google.android.gms.auth.api.signin.internal.SignInHubActivity}; have you declared this activity in your AndroidManifest.xml?``` Add the following to your AndroidManifest.xml ``` ``` ### Status Code 12501 (unknown) Your app signing or tokens are invalid 1. Check your app is signed with the same KeyStore noted in for your android app [Link](https://console.developers.google.com/apis/credentials) 2. Regenerate new OAuth 2 Client id, create the WebApplication kind. ## Native Facebook for Android Simple Auth supports the native Facebook SDK for Android. 1. Add the nuget [Clancey.SimpleAuth.Facebook.Droid](https://www.nuget.org/packages/Clancey.SimpleAuth.Facebook.Droid/) 2. Create an Android App: [Link](https://developers.facebook.com/docs/facebook-login/android) 3. Add the following to your String.xml in Resources/values. If your appId was 1066763793431980 ``` 1066763793431980 fb1066763793431980 ``` 4. Add a meta-data element to the application element: ``` [assembly: MetaData("com.facebook.sdk.ApplicationId", Value = "@string/facebook_app_id")] ``` 5. Add FacebookActivity to your AndroidManifest.xml: ``` ``` 6. Add the following code to your Main Activity ```cs protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SimpleAuth.Providers.Google.Init(this.Application); //The rest of your initialize code } protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); Native.OnActivityResult (requestCode,resultCode,data); } ``` ## CustomTabs for Android SimpleAuth supports using Custom Tabs for authorization. 1. Add the nuget [Clancey.SimpleAuth.Droid.CustomTabs](https://www.nuget.org/packages/Clancey.SimpleAuth.Droid.CustomTabs) 2. In your Droid project, create a subclass of SimpleAuthCallbackActivity to handle your url scheme, replacing the value of DataScheme with the scheme you used for the redirectUrl parameter of the Api constructor ```cs [Activity(NoHistory = true, LaunchMode = Android.Content.PM.LaunchMode.SingleTop)] [IntentFilter(new [] { Intent.ActionView}, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable}, DataScheme = "YOUR CUSTOM SCHEME")] public class MyCallbackActivity : SimpleAuthCallbackActivity { } ``` ## .Net Core You will need to implement an AuthStorage ```cs using System; using System.Collections.Generic; using System.IO; using System.Security.Cryptography; using System.Text; using System.Linq; namespace SimpleAuth { public class AuthStorage : IAuthStorage { private const int Keysize = 128; private const int DerivationIterations = 1000; public static string EncryptString(string plainText, string passPhrase) { var saltStringBytes = Generate256BitsOfRandomEntropy(); var ivStringBytes = Generate256BitsOfRandomEntropy(); var plainTextBytes = Encoding.UTF8.GetBytes(plainText); using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) { var keyBytes = password.GetBytes(Keysize / 8); using (var symmetricKey = new RijndaelManaged()) { symmetricKey.BlockSize = Keysize; symmetricKey.Mode = CipherMode.CBC; symmetricKey.Padding = PaddingMode.PKCS7; using (var encryptor = symmetricKey.CreateEncryptor(keyBytes, ivStringBytes)) { using (var memoryStream = new MemoryStream()) { using (var cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write)) { cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length); cryptoStream.FlushFinalBlock(); // Create the final bytes as a concatenation of the random salt bytes, the random iv bytes and the cipher bytes. var cipherTextBytes = saltStringBytes; cipherTextBytes = cipherTextBytes.Concat(ivStringBytes).ToArray(); cipherTextBytes = cipherTextBytes.Concat(memoryStream.ToArray()).ToArray(); memoryStream.Close(); cryptoStream.Close(); return Convert.ToBase64String(cipherTextBytes); } } } } } } public static string DecryptString(string cipherText, string passPhrase) { var cipherTextBytesWithSaltAndIv = Convert.FromBase64String(cipherText); var saltStringBytes = cipherTextBytesWithSaltAndIv.Take(Keysize / 8).ToArray(); var ivStringBytes = cipherTextBytesWithSaltAndIv.Skip(Keysize / 8).Take(Keysize / 8).ToArray(); var cipherTextBytes = cipherTextBytesWithSaltAndIv.Skip((Keysize / 8) * 2).Take(cipherTextBytesWithSaltAndIv.Length - ((Keysize / 8) * 2)).ToArray(); using (var password = new Rfc2898DeriveBytes(passPhrase, saltStringBytes, DerivationIterations)) { var keyBytes = password.GetBytes(Keysize / 8); using (var symmetricKey = new RijndaelManaged()) { symmetricKey.BlockSize = Keysize; symmetricKey.Mode = CipherMode.CBC; symmetricKey.Padding = PaddingMode.PKCS7; using (var decryptor = symmetricKey.CreateDecryptor(keyBytes, ivStringBytes)) { using (var memoryStream = new MemoryStream(cipherTextBytes)) { using (var cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read)) { var plainTextBytes = new byte[cipherTextBytes.Length]; var decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length); memoryStream.Close(); cryptoStream.Close(); return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount); } } } } } } private static byte[] Generate256BitsOfRandomEntropy() { var randomBytes = new byte[16]; using (var rngCsp = new RNGCryptoServiceProvider()) { rngCsp.GetBytes(randomBytes); } return randomBytes; } static string CalculateMD5Hash(string input) { var md5 = MD5.Create(); var inputBytes = Encoding.ASCII.GetBytes(input); var hash = md5.ComputeHash(inputBytes); var sb = new StringBuilder(); for (int i = 0; i < hash.Length; i++) { sb.Append(hash[i].ToString("X2")); } return sb.ToString(); } public void SetSecured(string identifier, string value, string clientId, string clientSecret, string sharedGroup) { var key = $"{clientId}-{identifier}-{clientId}-{sharedGroup}"; var newKey = CalculateMD5Hash(key); var encrypted = EncryptString(value, clientSecret); Plugin.Settings.CrossSettings.Current.AddOrUpdateValue(newKey, encrypted); } public string GetSecured(string identifier, string clientId, string clientSecret, string sharedGroup) { try { var key = $"{clientId}-{identifier}-{clientId}-{sharedGroup}"; var newKey = CalculateMD5Hash(key); var cryptText = Plugin.Settings.CrossSettings.Current.GetValueOrDefault(newKey, ""); return DecryptString(cryptText, clientSecret); } catch (Exception ex) { //Console.WriteLine(ex); } return null; } } } ``` For console apps, you will also need to implement the Authenticators: Basic Auth ```cs using System; using System.Security; using System.Threading.Tasks; namespace SimpleAuth { public class BasicAuthController { readonly IBasicAuthenicator authenticator; public BasicAuthController(IBasicAuthenicator authenticator) { this.authenticator = authenticator; } public async Task> GetCredentials(string title, string details = "") { try { Console.WriteLine("******************"); Console.WriteLine(title); Console.WriteLine(details); Console.WriteLine("******************"); Console.WriteLine("Enter Username:"); var username = Console.ReadLine(); Console.WriteLine("Enter Password:"); var password = GetPassword(); var result = new Tuple(username, password); try { bool success = false; var basic = authenticator; if (basic != null) { success = await basic.VerifyCredentials(result.Item1, result.Item2); } if (!success) throw new Exception("Invalid Credentials"); } catch (Exception ex) { result = await GetCredentials(title, $"Error: {ex.Message}"); } return result; } catch (TaskCanceledException) { authenticator.OnCancelled(); return null; } } public string GetPassword() { var pwd = ""; while (true) { ConsoleKeyInfo i = Console.ReadKey(true); if (i.Key == ConsoleKey.Enter) { break; } else if (i.Key == ConsoleKey.Backspace) { if (pwd.Length > 0) { pwd.Remove(pwd.Length - 1); Console.Write("\b \b"); } } else { pwd += (i.KeyChar); Console.Write("*"); } } return pwd; } } } ``` Web Authenticator ```cs using System; using System.Threading.Tasks; using System.Diagnostics; using System.Runtime.InteropServices; namespace SimpleAuth { public class WebAuthenticatorController { readonly WebAuthenticator authenticator; public WebAuthenticatorController(WebAuthenticator authenticator) { this.authenticator = authenticator; } public async Task GetCredentials(string title, string details = "") { try { var url = await authenticator.GetInitialUrl(); Console.WriteLine("******************"); Console.WriteLine(title); Console.WriteLine(details); Console.WriteLine($"Launching Url: \"{url}\""); Console.WriteLine("******************"); Console.WriteLine("Paste the Redirected URL Here:"); OpenBrowser(url); var username = Console.ReadLine(); try { bool success = false; var basic = authenticator; if (basic != null) { success = basic.CheckUrl(new Uri(username), null); } if (!success) throw new Exception("Invalid Credentials"); } catch (Exception ex) { await GetCredentials(title, $"Error: {ex.Message}"); } } catch (TaskCanceledException) { authenticator.OnCancelled(); } } public static void OpenBrowser(Uri uri) { OpenBrowser(uri.AbsoluteUri); } public static void OpenBrowser(string url) { try { Process.Start(url); } catch { // hack because of this: https://github.com/dotnet/corefx/issues/10361 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { url = url.Replace("&", "^&"); Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Process.Start("xdg-open", url); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { Process.Start("open", url); } else { throw; } } } } } ``` ================================================ FILE: SimpleAuth.Droid.CustomTabs.nuspec ================================================  Clancey.SimpleAuth.Droid.CustomTabs 1.0.3 Clancey https://github.com/Clancey/SimpleAuth/blob/master/LICENSE https://github.com/clancey/SimpleAuth false Adds CustomTabs support to SimpleAuth Updated dependencies James Clancey ================================================ FILE: SimpleAuth.Facebook.Droid.nuspec ================================================  Clancey.SimpleAuth.Facebook.Droid 1.0.6 Clancey https://github.com/Clancey/SimpleAuth/blob/master/LICENSE https://github.com/clancey/SimpleAuth false Native Facebook support for SimpleAuth Updated dependencies James Clancey ================================================ FILE: SimpleAuth.Facebook.iOS.nuspec ================================================  Clancey.SimpleAuth.Facebook.iOS 1.0.7 Clancey https://github.com/Clancey/SimpleAuth/blob/master/LICENSE https://github.com/clancey/SimpleAuth false Native Facebook support for SimpleAuth Added hookeups for Simplified plugins Required Callbacks: SimpleAuth.Providers.Facebook.Init(app, options); SimpleAuth.Native.OpenUrl(application, url, options); Updated Dependencies James Clancey ================================================ FILE: SimpleAuth.Google.Droid.nuspec ================================================  Clancey.SimpleAuth.Google.Droid 1.0.13 Clancey https://github.com/Clancey/SimpleAuth/blob/master/LICENSE https://github.com/clancey/SimpleAuth false Native Google support for SimpleAuth Updated dependencies James Clancey ================================================ FILE: SimpleAuth.Google.iOS.nuspec ================================================  Clancey.SimpleAuth.Google.iOS 1.0.4 Clancey https://github.com/Clancey/SimpleAuth/blob/master/LICENSE https://github.com/clancey/SimpleAuth false Native Google support for SimpleAuth Just call SimpleAuth.Providers.Google.Init(); Required Callbacks: SimpleAuth.Native.OpenUrl(application, url, options); Updated dependencies James Clancey ================================================ FILE: SimpleAuth.nuspec ================================================  Clancey.SimpleAuth 1.0.56 Clancey https://github.com/Clancey/SimpleAuth/blob/master/LICENSE https://github.com/clancey/SimpleAuth false The Simplest OAuth client for Xamarin and UWP Every API needs authentication, yet no developer wants to deal with authentication. Simple Auth embeds authentication into the API so you dont need to deal with it. Added WKWebView for iOS James Clancey ================================================ FILE: samples/.nuget/NuGet.Config ================================================  ================================================ FILE: samples/Sample.Droid/Assets/AboutAssets.txt ================================================ Any raw assets you want to be deployed with your application can be placed in this directory (and child directories) and given a Build Action of "AndroidAsset". These files will be deployed with you package and will be accessible using Android's AssetManager, like this: public class ReadAsset : Activity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); InputStream input = Assets.Open ("my_asset.txt"); } } Additionally, some Android functions will automatically load asset files: Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); ================================================ FILE: samples/Sample.Droid/MainActivity.cs ================================================ using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; using SimpleAuth; using Android.Support.V4.App; using System.Threading.Tasks; [assembly: MetaData ("com.facebook.sdk.ApplicationId", Value = "@string/facebook_app_id")] namespace Sample.Droid { // We need to give the activity an explicit name for our acvitity that we provide to Facebook when we setup the app // in the dev console, so it can callback to the right deep link. [Activity (Label = "Sample.Droid", MainLauncher = true, Icon = "@drawable/icon", Name = "com.simpleauth.sample.MainActivity")] public class MainActivity : FragmentActivity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); // Initialize our native providers SimpleAuth.Providers.Google.Init (this.Application); //SimpleAuth.Providers.Facebook.Init(this.Application, false); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); FindViewById ================================================ FILE: samples/Sample.Mac/MainWindowController.cs ================================================ using System; using Foundation; using AppKit; using SimpleAuth.Providers; using SimpleAuth; using System.Threading.Tasks; namespace Sample.Mac { public partial class MainWindowController : NSWindowController { InstagramApi api; public MainWindowController(IntPtr handle) : base(handle) { } [Export("initWithCoder:")] public MainWindowController(NSCoder coder) : base(coder) { } public MainWindowController() : base("MainWindow") { } public static string ClientId = "992461286651-k3tsbcreniknqptanrugsetiimt0lkvo.apps.googleusercontent.com"; public static string ClientSecret = "avrYAIxweNZwcHpsBlIzTp04"; public override void AwakeFromNib() { base.AwakeFromNib(); var scopes = new[] { "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile" }; api = new InstagramApi("instagram", ClientId, ClientSecret) { Scopes = scopes, }; } public new MainWindow Window { get { return (MainWindow)base.Window; } } partial void Login (Foundation.NSObject sender) { Login(); } async void Login() { try { var account = await api.Authenticate(); //var info = await api.GetUserInfo(); Console.WriteLine(account.Identifier); } catch (TaskCanceledException ex) { Console.WriteLine("Canceled"); } } } } ================================================ FILE: samples/Sample.Mac/MainWindowController.designer.cs ================================================ // WARNING // // This file has been generated automatically by Xamarin Studio to store outlets and // actions made in the UI designer. If it is removed, they will be lost. // Manual changes to this file may not be handled correctly. // using Foundation; using System.CodeDom.Compiler; namespace Sample.Mac { [Register ("MainWindowController")] partial class MainWindowController { [Outlet] AppKit.NSButton LoginButton { get; set; } [Action ("Login:")] partial void Login (Foundation.NSObject sender); void ReleaseDesignerOutlets () { if (LoginButton != null) { LoginButton.Dispose (); LoginButton = null; } } } } ================================================ FILE: samples/Sample.Mac/Resources/Images.xcassets/AppIcons.appiconset/Contents.json ================================================ { "images": [ { "size": "29x29", "scale": "1x", "idiom": "iphone" }, { "size": "29x29", "scale": "2x", "idiom": "iphone" }, { "size": "29x29", "scale": "3x", "idiom": "iphone" }, { "size": "40x40", "scale": "2x", "idiom": "iphone" }, { "size": "40x40", "scale": "3x", "idiom": "iphone" }, { "size": "57x57", "scale": "1x", "idiom": "iphone" }, { "size": "57x57", "scale": "2x", "idiom": "iphone" }, { "size": "60x60", "scale": "2x", "idiom": "iphone" }, { "size": "60x60", "scale": "3x", "idiom": "iphone" }, { "size": "29x29", "scale": "1x", "idiom": "ipad" }, { "size": "29x29", "scale": "2x", "idiom": "ipad" }, { "size": "40x40", "scale": "1x", "idiom": "ipad" }, { "size": "40x40", "scale": "2x", "idiom": "ipad" }, { "size": "50x50", "scale": "1x", "idiom": "ipad" }, { "size": "50x50", "scale": "2x", "idiom": "ipad" }, { "size": "72x72", "scale": "1x", "idiom": "ipad" }, { "size": "72x72", "scale": "2x", "idiom": "ipad" }, { "size": "76x76", "scale": "1x", "idiom": "ipad" }, { "size": "76x76", "scale": "2x", "idiom": "ipad" }, { "size": "120x120", "scale": "1x", "idiom": "car" }, { "role": "notificationCenter", "size": "24x24", "subtype": "38mm", "scale": "2x", "idiom": "watch" }, { "role": "notificationCenter", "size": "27.5x27.5", "subtype": "42mm", "scale": "2x", "idiom": "watch" }, { "role": "companionSettings", "size": "29x29", "scale": "2x", "idiom": "watch" }, { "role": "companionSettings", "size": "29x29", "scale": "3x", "idiom": "watch" }, { "role": "appLauncher", "size": "40x40", "subtype": "38mm", "scale": "2x", "idiom": "watch" }, { "role": "longLook", "size": "44x44", "subtype": "42mm", "scale": "2x", "idiom": "watch" }, { "role": "quickLook", "size": "86x86", "subtype": "38mm", "scale": "2x", "idiom": "watch" }, { "role": "quickLook", "size": "98x98", "subtype": "42mm", "scale": "2x", "idiom": "watch" }, { "filename": "AppIcon-16.png", "size": "16x16", "scale": "1x", "idiom": "mac" }, { "filename": "AppIcon-16@2x.png", "size": "16x16", "scale": "2x", "idiom": "mac" }, { "filename": "AppIcon-32.png", "size": "32x32", "scale": "1x", "idiom": "mac" }, { "filename": "AppIcon-32@2x.png", "size": "32x32", "scale": "2x", "idiom": "mac" }, { "filename": "AppIcon-128.png", "size": "128x128", "scale": "1x", "idiom": "mac" }, { "filename": "AppIcon-128@2x.png", "size": "128x128", "scale": "2x", "idiom": "mac" }, { "filename": "AppIcon-256.png", "size": "256x256", "scale": "1x", "idiom": "mac" }, { "filename": "AppIcon-256@2x.png", "size": "256x256", "scale": "2x", "idiom": "mac" }, { "filename": "AppIcon-512.png", "size": "512x512", "scale": "1x", "idiom": "mac" }, { "filename": "AppIcon-512@2x.png", "size": "512x512", "scale": "2x", "idiom": "mac" } ], "info": { "version": 1, "author": "xcode" } } ================================================ FILE: samples/Sample.Mac/Sample.Mac.csproj ================================================ Debug AnyCPU {A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} {48662D2B-ABBD-4118-972A-752F1817747D} Exe Sample.Mac Resources Sample.Mac Xamarin.Mac v2.0 true full false bin\Debug DEBUG; prompt 4 false true true true false false Mac Developer false false None full true bin\Release prompt 4 false SdkOnly false true true true true Developer ID Application true false None MainWindow.cs MainWindowController.cs AppDelegate.cs {6457641D-D20D-479B-AA3B-30A9C88B96DE} SimpleAuth.Mac ================================================ FILE: samples/Sample.Maui/App.xaml ================================================  ================================================ FILE: samples/Sample.Maui/App.xaml.cs ================================================ using SimpleAuth; using SimpleAuth.Providers; namespace Sample.Maui; public partial class App : Application { AuthenticatedApi _sourceApi; public App() { //Hook up our Forms login page for Basic Auth BasicAuthApi.ShowAuthenticator = (IBasicAuthenicator obj) => { MainPage.Navigation.PushModalAsync(new LoginPage(obj)); }; string FacebookClientId = "528997441203195"; string FacebookSecret = "db801dd6f6bc40702ebbd70ecdef4d4e"; string InstagramClientId = "f2c421d810824581ac758861e56e5340"; string InstagramSecret = "2465b93d4cc44355a4ccf32f3eca707a"; #if __ANDROID__ string GoogleClientId = "646679266669-quj4b4frm8gi4knn6269me7ss9cefj7c.apps.googleusercontent.com"; string GoogleSecret = GoogleApi.NativeClientSecret; //"uzj06SA8A66Y9mOA1rSjmQH7"; #else string GoogleClientId = "992461286651-k3tsbcreniknqptanrugsetiimt0lkvo.apps.googleusercontent.com"; string GoogleSecret = "avrYAIxweNZwcHpsBlIzTp04"; #endif var logoutButton = new Button() { Text = "Logout" }; logoutButton.Clicked += async (sender, args) => { if (_sourceApi != null) { _sourceApi.Logout(); _sourceApi = null; } }; // The root page of your application MainPage = new NavigationPage(new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { CreateApiButton( new GoogleApi("google", GoogleClientId, GoogleSecret) { Scopes = new[] { "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile" }, }), CreateApiButton(new FacebookApi("facebook", FacebookClientId, FacebookSecret)), CreateApiButton(new InstagramApi("instagram" ,InstagramClientId, InstagramSecret)), CreateApiButton(new OAuthPasswordApi ("myapi", "clientid", "clientsecret", "https://serverurl.com", "https://tokenurl.com", "https://refreshurl.com")), logoutButton } } }); } Button CreateApiButton(AuthenticatedApi api) { var button = new Button { Text = $"Login: {api.GetType().Name}", }; button.Clicked += async (sender, args) => { try { _sourceApi = api; var account = await api.Authenticate() as OAuthAccount; Console.WriteLine(account.Identifier + " : " + account.Token); await MainPage.DisplayAlert("Success!", "User is logged in", "Ok"); } catch (TaskCanceledException) { Console.WriteLine("Canceled"); await MainPage.DisplayAlert("Error", "User Canceled", "Ok"); } catch (Exception ex) { Console.WriteLine(ex); await MainPage.DisplayAlert("Error", ex.Message, "Ok"); } }; return button; } } ================================================ FILE: samples/Sample.Maui/LoginPage.xaml ================================================