Comments (7)
Hi John,
What is the meta-data that you are trying to fetch? You can add metadata to the idToken which is returned by the lib as idTokenPayload alternatively, you can make a call to the /userinfo endpoint in both the cases any non standard metadata will needed to be added to the profile / idToken as described at https://auth0.com/docs/rules/current#copy-user-metadata-to-id-token
from auth0-cordova.
not /userInfo (I think), I have that working great thanks!
I am talking about the "user_metadata" value that auth0 exposes.
I'm still getting to grips with auth0 but as the admin interface states the user has write control over this value and with this in mind I'm looking for it to be an easy way for a user to store and retrieve a simple value.
I was expecting something like..
auth0.client.set("user_metadata", {foo: "bar"}, function(){});
Like I said I'm a huge noob to auth0 but I don't feel like https://auth0.com/docs/rules/current#copy-user-metadata-to-id-token does this... Happy to be proven wrong though!
from auth0-cordova.
Hello,
I'm working with John on this project. We basicly want to store a bit of data with each user, its just a string basicly, its all the information we need to store for a user for our specific use case.
I read a bit through the API docs. I understand how we can set meta data via the management API. But I don't understand yet how to read it via the Authentication API. Ideally we could retrieve the metadata at any moment, long after the initial authentication happened. Is this possible? I looked a bit into rules and idtoken but didn't manage to wrap my head around it.
Hope that clearifies things a bit
Peter
from auth0-cordova.
We decided to workaround auth0 in this instance (somewhat) by just using the bearer and sub..
Here is the example code we used to set and get metadata...
You will need to set SUB and IDTOKEN -- these values are available in the auth0.client object.
First we SET(PATCH) the value..
var url = "https://DOMAIN.auth0.com/api/v2/users/"+SUB;
$.ajax({
method: "PATCH",
url: url,
data: {
user_metadata: {
whatever: "somevalue"
}
},
headers: {
'authorization': "Bearer "+IDTOKEN
},
success: function(d){
console.log("success", d);
},
error: function(e){
console.log("error getting metadata", e)
}
})
and here we GET the value..
var url = "https://DOMAIN.auth0.com/api/v2/users/"+SUB+"?fields=user_metadata";
$.get({
url: url,
headers: {
'authorization': "Bearer "+IDTOKEN
},
success: function(d){
console.log("success", d)
if(d.user_metadata){
console.log(d.user_metadata); // should be {whatever: "somevalue"}
}
},
error: function(e){
console.log("error getting metadata", e)
}
})
Sorry if we took a slightly hacky approach but it works and we can manage it so... If auth0 want to provide a cleaner approach that fits more inline with the API I'm all ears :)
from auth0-cordova.
Hi John, This is a historically legacy feature that works for now (basically allows you to have current_user) access through the ID_Token in future you should be able to get tokens for Management API directly with the scope for current_user. I'll get back to you with the blueprint for that.
from auth0-cordova.
Thanks I'd like to make sure I'm not using something that will be deprecated in x months! :)
from auth0-cordova.
Bump :)
from auth0-cordova.
Related Issues (20)
- Handling errors in redirect uri HOT 1
- Capacitor support HOT 13
- onRedirectUri faulty behavior after first login HOT 8
- Module not found: Error: Can't resolve 'crypto' in 'C://mypc/path/node_module/@auth0\cordova\src' HOT 1
- Angular support HOT 4
- Login screen hangs after entering credentials HOT 9
- Refresh tokens HOT 6
- iOS social provider signout problem HOT 3
- Custom Webpack is not used when using livereload on cordova run HOT 6
- Sign in with Apple - error on callback HOT 22
- Universal and Deep link support for iOS and Android HOT 3
- Use ASWebAuthenticationSessionManager with cordova HOT 4
- New Version Release HOT 1
- Cannot read properties of undefined (reading 'open') HOT 1
- net: ERR_UNKNOWN_URL_SCHEME with targetSdkVersion 30 HOT 11
- loading icon keeps spinning after social sign in using ionic V3 app on Android
- Could not load module crypto HOT 3
- New Release? HOT 1
- Login with Google is not asking the account to use HOT 2
- SafariViewController Closes before user can save or update password HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auth0-cordova.