peterhorsley / unity3d.authentication.example Goto Github PK
View Code? Open in Web Editor NEWUnity3D Android/iOS Authentication Example
License: MIT License
Unity3D Android/iOS Authentication Example
License: MIT License
First off, thanks for this example implementation. It has been extremely helpful in getting up and running with OAuth through IdentityServer in Unity.
Currently, the Unity Implementation expects a GameObject named "SignInCanvas" to have a script with an "OnAuthReply(string)" method to receive the response from the platform specific web view. I have not found this documented anywhere in this repo.
My suggestion is to add a line to the README documenting this. Additionally, a config option to change this name would be useful.
Thanks again for this extremely useful example!
The Canvas name is hardcoded in the AndroidProject: To use the Activity behind the plugin with your own project (your own scenes/canvas), you need to rename your Canvas to the same name used in demo project. Better solution would be to changed it in AndroidProject but then you have to re-build the AndroidUnityPlugin.jar file.
Edit: Realized there is already a issue for that: #1
We have the package working successfully with our endpoint, but when we try to use google single sign on it seems to create an error.
Is this intended to work?
Thanks
Ben
Could you please indicate where I can find the missing file? On ReadMe file there is the instruction to put it under assets folder, but I cannot find the respective file.
Hello there !
The project freshly opened won't compile with error as shown below.
I also tried adding Link Binary with libraries AuthenticationServices.framework and SafariServices.framework both to optional but same error shows. Guidance appreciated please !
Ld /Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhzlnylgols/Build/Products/Debug-iphoneos/appname.app/appname normal (in target 'Unity-iPhone' from project 'Unity-iPhone')
cd /Users/myusername/Documents/Work/AppAuth/DevBuild/AppAuthapp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target arm64-apple-ios13.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk -L/Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhzlnylgols/Build/Products/Debug-iphoneos -L/Users/myusername/Documents/Work/AppAuth/DevBuild/AppAuthapp -L/Users/myusername/Documents/Work/AppAuth/DevBuild/AppAuthapp/Libraries -F/Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhehiwzlnylgols/Build/Products/Debug-iphoneos -filelist /Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhehiwzlnylgols/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/appname.LinkFileList -Xlinker -map -Xlinker /Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhehiwzlnylgols/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/appname-LinkMap-normal-arm64.txt -dead_strip -Xlinker -object_path_lto -Xlinker /Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhehiwzlnylgols/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/appname_lto.o -Xlinker -no_deduplicate -fembed-bitcode-marker -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -weak_framework CoreMotion -weak-lSystem -framework Security -framework MediaToolbox -liPhone-lib -framework CoreText -framework AudioToolbox -weak_framework AVFoundation -framework AVKit -framework CFNetwork -framework CoreGraphics -framework CoreMedia -weak_framework CoreMotion -framework CoreVideo -framework Foundation -framework OpenAL -framework OpenGLES -framework QuartzCore -framework SystemConfiguration -framework UIKit -liconv.2 -lil2cpp -weak_framework Metal -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhehiwzlnylgols/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/arm64/appname_dependency_info.dat -o /Users/myusername/Library/Developer/Xcode/DerivedData/Unity-iPhone-hiikkwzqdiflfbhehiwzlnylgols/Build/Products/Debug-iphoneos/appname.app/appname
Undefined symbols for architecture arm64:
"OBJC_CLASS$_SFSafariViewController", referenced from:
objc-class-ref in SafariView.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Can you explain how refresh tokens work?
If a token is due to expire, how do you request a new refresh token?
as the title says, i can't seems to find this project might already be deleted. is there any more information on this ?
When I click logout, the button changes to PLEASE WAIT and does not go any further.
Running on commit 7f8b388, cause that's the latest one working on iOS properly. Unity 2018.2.21f. iOS 12.1.4
Here are the logs:
SignInBehavior::Start
SignInBehavior::Signing in...
UnityAuthLogger: Trace, , LoginAsync
UnityAuthLogger: Information, , Starting authentication request.
UnityAuthLogger: Trace, , EnsureProviderInformation
MonoRemoteCertificateValidationCallback
UnityAuthLogger: Debug, , Successfully loaded discovery document
UnityAuthLogger: Debug, , Loaded keyset from https://demo.identityserver.io/.well-known/openid-configuration/jwks
UnityAuthLogger: Debug, , Keyet contains the following kids: baa666f56ffcee251e4cc6e43c246ef0
UnityAuthLogger: Trace, , Effective options:
UnityAuthLogger: Trace, , Logging has been disabled
UnityAuthLogger: Trace, , AuthorizeAsync
UnityAuthLogger: Trace, , CreateAuthorizeStateAsync
UnityAuthLogger: Trace, , CreatePkceData
UnityAuthLogger: Trace, , CreateNonce
UnityAuthLogger: Trace, , CreateState
UnityAuthLogger: Trace, , CreateAuthorizeUrl
UnityAuthLogger: Trace, , CreateAuthorizeParameters
UnityAuthLogger: Trace, , ObjectToDictionary
UnityAuthLogger: Debug, , Logging has been disabled
2019-04-30 12:45:21.283920+0200 unityclient[555:124025] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-04-30 12:45:21.284170+0200 unityclient[555:124025] [MC] Reading from public effective user settings.
2019-04-30 12:45:24.755472+0200 unityclient[555:124025] [Common] _BSMachError: port 11613; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
2019-04-30 12:45:32.076053+0200 unityclient[555:124025] url received io.identitymodel.native://callback?code=5c19d9e293b0a6f07a1dbd6ae854869e6b63c76c6f2990cb0ec2924514a17e5b&scope=openid%20profile%20email&state=d1f4e44bfa51c0d4e5f69b7c6a89d8ea&session_state=4OZ1W1V7P6sWAmO0607DsQJsCN8g-VvJg9Tny5JuhfI.bb0de00a5c30b6f1edbfa0fc24f70d89
2019-04-30 12:45:32.076242+0200 unityclient[555:124025] received auth reply with query string
SignInBehavior::OnAuthReply: code=5c19d9e293b0a6f07a1dbd6ae854869e6b63c76c6f2990cb0ec2924514a17e5b&scope=openid%20profile%20email&state=d1f4e44bfa51c0d4e5f69b7c6a89d8ea&session_state=4OZ1W1V7P6sWAmO0607DsQJsCN8g-VvJg9Tny5JuhfI.bb0de00a5c30b6f1edbfa0fc24f70d89
MobileBrowser.OnAuthReply: code=5c19d9e293b0a6f07a1dbd6ae854869e6b63c76c6f2990cb0ec2924514a17e5b&scope=openid%20profile%20email&state=d1f4e44bfa51c0d4e5f69b7c6a89d8ea&session_state=4OZ1W1V7P6sWAmO0607DsQJsCN8g-VvJg9Tny5JuhfI.bb0de00a5c30b6f1edbfa0fc24f70d89
UnityAuthLogger: Trace, , ProcessResponseAsync
UnityAuthLogger: Information, , Processing response.
UnityAuthLogger: Trace, , EnsureProviderInformation
UnityAuthLogger: Debug, , Successfully loaded discovery document
UnityAuthLogger: Debug, , Loaded keyset from https://demo.identityserver.io/.well-known/openid-configuration/jwks
UnityAuthLogger: Debug, , Keyet contains the following kids: baa666f56ffcee251e4cc6e43c246ef0
UnityAuthLogger: Trace, , Effective options:
UnityAuthLogger: Trace, , Logging has been disabled
UnityAuthLogger: Debug, , Authorize response: code=5c19d9e293b0a6f07a1dbd6ae854869e6b63c76c6f2990cb0ec2924514a17e5b&scope=openid%20profile%20email&state=d1f4e44bfa51c0d4e5f69b7c6a89d8ea&session_state=4OZ1W1V7P6sWAmO0607DsQJsCN8g-VvJg9Tny5JuhfI.bb0de00a5c30b6f1edbfa0fc24f70d89
UnityAuthLogger: Trace, , ProcessResponseAsync
UnityAuthLogger: Trace, , ProcessCodeFlowResponseAsync
UnityAuthLogger: Trace, , RedeemCodeAsync
UnityAuthLogger: Trace, , ValidateTokenResponse
UnityAuthLogger: Trace, , Validate
UnityAuthLogger: Debug, , Added signing key with kid: baa666f56ffcee251e4cc6e43c246ef0
UnityAuthLogger: Trace, , ValidateNonce
UnityAuthLogger: Trace, , ValidateHash
UnityAuthLogger: Trace, , GetMatchingHashAlgorithm
UnityAuthLogger: Debug, , Determining matching hash algorithm for RS256
UnityAuthLogger: Debug, , SHA256
UnityAuthLogger: Trace, , GetUserInfoAsync
UnityAuthLogger: Trace, , EnsureProviderInformation
UnityAuthLogger: Debug, , Successfully loaded discovery document
UnityAuthLogger: Debug, , Loaded keyset from https://demo.identityserver.io/.well-known/openid-configuration/jwks
UnityAuthLogger: Debug, , Keyet contains the following kids: baa666f56ffcee251e4cc6e43c246ef0
UnityAuthLogger: Trace, , Effective options:
UnityAuthLogger: Trace, , Logging has been disabled
UnityAuthLogger: Trace, , ProcessClaims
UnityAuthLogger: Information, , Authentication request success.
UnityAuthClient::Dismissing sign-in browser.
UnityAuthClient::AccessToken: eyJhbGciOiJSUzI1NiIsImtpZCI6ImJhYTY2NmY1NmZmY2VlMjUxZTRjYzZlNDNjMjQ2ZWYwIiwidHlwIjoiSldUIn0.eyJuYmYiOjE1NTY2MjExMzIsImV4cCI6MTU1NjYyNDczMiwiaXNzIjoiaHR0cHM6Ly9kZW1vLmlkZW50aXR5c2VydmVyLmlvIiwiYXVkIjoiaHR0cHM6Ly9kZW1vLmlkZW50aXR5c2VydmVyLmlvL3Jlc291cmNlcyIsImNsaWVudF9pZCI6Im5hdGl2ZS5jb2RlIiwic3ViIjoiMTEiLCJhdXRoX3RpbWUiOjE1NTY2MjExMzEsImlkcCI6ImxvY2FsIiwic2NvcGUiOlsib3BlbmlkIiwicHJvZmlsZSIsImVtYWlsIl0sImFtciI6WyJwd2QiXX0.cautWTzpOzp-udlp3jMJ_WA-ZwFZDkvFZnpIggpZvmkhW8ggBeuBF-MPS2pT8GlHem3_mepztFP5BP19lAMX-2or0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IjryUizTYJ2v5_0uL8QJJnuJ9gP_CAb15rKa4r9K9wvYduPSg
UnityAuthClient::Signed in.
SignInBehavior::Signing out...
UnityAuthLogger: Trace, , EnsureProviderInformation
UnityAuthLogger: Debug, , Successfully loaded discovery document
UnityAuthLogger: Debug, , Loaded keyset from https://demo.identityserver.io/.well-known/openid-configuration/jwks
UnityAuthLogger: Debug, , Keyet contains the following kids: baa666f56ffcee251e4cc6e43c246ef0
UnityAuthLogger: Trace, , Effective options:
UnityAuthLogger: Trace, , Logging has been disabled
UnityAuthLogger: Trace, , CreateEndSessionUrl
Following the steps provided:
"Unity does not support nuget nicely, so you must clone and compile IdentityModel.OidcClient2 solution using Visual Studio 2017.
Copy the release binaries from IdentityModel.OidcClient/bin/release/net452 to a folder in your Unity project's Assets folder.
Delete System.Runtime.InteropServices.RuntimeInformation.dll as this DLL is not compatible with Unity."
I needed to change the "code id_token" strings to "code" and attempted a recompile. Dragging in the new binaries to Unity I have compile error for LogSerializer
"Assets/UnityAuthClient.cs(23,13): error CS0122: `IdentityModel.OidcClient.Infrastructure.LogSerializer' is inaccessible due to its protection level"
Please advise
Hey everyone, after trying to get this to work for the past day or so on iOS with the app I am working on I found some things that didn't make it into the documentation to make iOS work with different Redirect URI's that the example provided.
First off, in the 'iOS support' section, you guys mention the file 'OAuthUnityAppController.mm'. There is no such file, but instead its just 'AuthUnityAppController.mm'. This confused me at first and may need to be changed for future users (documentation or file name).
Secondly, once you change the RedirectUri in the OidcClientOptions you need to change it in that 'AuthUnityAppController.mm' to match (without the "://callback" appended). But that isn't the only place you need to change. In 'BuildPostProcess.cs' you will have to change the registering url schemes to match your app's info. Including the app's bundle identifier and URL scheme (the redirect uri). Changing those made it finally work for me!
Thanks for the great plugin guys!
README says
Derive an objective-c class from UnityAppController to handle auth redirects (see OAuthUnityAppController.mm).
But the class is actually called AuthUnityAppController.mm. It might seem small, but I was looking in the ios plugins folder for a file called OAuthUnityAppController.mm and when I couldn't find one my first assumption was that it had somehow gone missing or the documentation was just wrong.
Hey Peter, highly appreciate the work you have done. Concerning iOS, you developed the only sample I could find. We'd like to use the authentication in an productive environment. I tried to find the bug myself but with no luck. Would highly appreciate it, if you could give me a clue what I'm doing wrong. I added a recording.
Steps before:
what you may not see: I clicked on "Login", the uri changed very briefly. After that I waited for 1 or 2 seconds and tried "Login" once more. After that the browser shows no content any more.
Unity 2018.3.1 and 2018.3.3
iOS 12.1
XCode 10.1
The sample https://github.com/IdentityModel/IdentityModel.OidcClient.Samples/tree/master/iOS11Client is working correctly
Note: There is no system-dialog popup for thirdparty service concerning login like in normal iOS sample
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.