I don't find how to get the user_metadata from the Auth0 Authentication api:
$auth0Api = new Authentication($domain, $clientId, $clientSecret);
$tokenInfo = $auth0Api->login([
'username' => $username,
'password' => $password,
'realm' => 'Username-Password-Authentication',
]);
$accessToken = $tokenInfo["access_token"];
$info = $auth0Api->userinfo($accessToken);
The final $info array only contains the main user information, no meta_data at all. I tried creating a rule from the Auth0 side to add stuff to the user itself (doing user.customtag = 'helloworld' for example) and the customization does not show either.
User info retrieved:
{
"sub":"auth0|XXXX",
"name":"XXXX#XXXX.com",
"nickname":"XXXX",
"picture":"XXXX.png",
"updated_at":"2017-03-31T08:50:59.819Z",
"email":"XXXX#XXXX.com",
"email_verified":true
}
The "Raw Json" tab of that user shows something much more complete:
{
"email": "XXXX#XXXX.com",
"email_verified": true,
"user_id": "auth0|XXXX",
"picture": "XXXX.png",
"nickname": "XXXX",
"identities": [
{
"user_id": "XXXX",
"provider": "auth0",
"connection": "Username-Password-Authentication",
"isSocial": false
}
],
"updated_at": "2017-03-31T08:50:59.819Z",
"created_at": "2017-03-23T16:03:47.075Z",
"name": "XXXX",
"user_metadata": {
"languageCode": "EN"
},
"last_ip": "XXXX",
"last_login": "XXXX",
"logins_count": XXXX,
"blocked_for": [],
"guardian_enrollments": []
}
How is it supposed to work?
Environment:
composer: "auth0/auth0-php": "~5.0"
php 7.1
Auth0 Free account
Try starting up your application locally, then update the following URL with your own settings and paste it into a web browser:
https://YOUR_TENANT.auth0.com/authorize?client_id=YOUR_CLIENT_ID&response_type=code&scope=openid profile&redirect_uri=YOUR_REDIRECT_URI&nonce=12345
This should at least ensure you are making a request with right scopes etc. You should also ensure you have a User Profile with some "metadata" assigned if you are expecting to read that data post authentication of course ;)
Related
my server timezone is London and we are in Indian standard Time, everything works fine, except when the jwt and refresh token both expires, I have a scenario where I have to generate a new refresh token with 1 hr validity and supply for the final execution to happen for my mobile app to sync all the data from mobile app to the server.
I am getting this error
Error: Cannot handle token prior to 2022-11-25T22:41:29+0530"
when i check it on postman it works fine but when it run from the mobile app it gives error
JWT Payload Data
{ "iss": "website address", "iat": 1669273766, "nbf": 1669273776, "exp": 1669273826, "aud": "myusers", "data": { "id": 1, "mobilenumber": "XXXXXXXXXXX", "email": "XXXXX#XXX.com", "deviceimeino": "XXXXXXXX", "deveventid": xxxx, "eventexpirydate": { "date": "2022-11-24 23:59:59.000000", "timezone_type": 3, "timezone": "Asia/Calcutta" } } }
Refresh Token Payload Data
{ "iss": "website address", "iat": 1669436131, "nbf": 1669436141, "exp": 1669439727, "aud": "myusers", "data": { "id": 1, "mobilenumber": "xxxxxx", "email": "xxxx#xxx.com", "deviceimeino": "xxxxxxx", "deveventid": xxx, "eventexpirydate": "2022-11-03 23:59:59" } }
there I am new to WordPress.
I have created a Login API, using the plugin called simple jwt login, but it returns me the response like this.
{
"success": true,
"data": {
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NTI4NTQxNTEsImVtYWlsIjoiYWJkdWxsYWhAbnJ0Y2dyb3VwLmNvbSIsImlkIjo3NTcwMCwic2l0ZSI6Imh0dHA6XC9cLzIwLjEyNi4xMjEuMTEyXC9ucnRjIiwidXNlcm5hbWUiOiJhYmR1bGxhaEBucnRjZ3JvdXAuY29tIiwidXNlcklkIjo3NTcwMCwib2xkVXNlcklkIjpudWxsLCJkaXNwbGF5X25hbWUiOiJBYmR1YWxsYWggdGVzdCIsInNlc3Npb25JZCI6Im9paGNuMmdrZXFpOWRxa25lZTRkbHVrMWJnIiwiaXNzIjoiYXBwQHNlY3VyZS5ucnRjZnJlc2guY29tIiwic3ViIjoiYXBwQHNlY3VyZS5ucnRjZnJlc2guY29tIiwiZXhwIjoxNjUyODU0MTUxLCJraW5kIjoiYXV0aC10b2tlbiIsInJvbGVzIjpbImN1c3RvbWVyIl0sImNvY2FydF9rZXkiOnsiY19rZXkiOiJja18xMGFiMDJiYTdjMDJlYmU1ZTliZmQwNjg4M2Q1MDc4NjQ0MTI0ZGMxIiwiY19zZWNyZXQiOiJjc19lODMwOWUwODFlYTZmNTkzNTE3MWYyMDE4OGZiZTUyNjliZDhmZTBlIn19.MSWyFCyu6D88dj2MhD7MrV9x1-L7MUnFS4WAKyc_ALo"
}
}
--> But I am looking for the response like this:
{
"success": true,
"data": {
"jwt": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NTI4NTQxNTEsImVtYWlsIjoiYWJkdWxsYWhAbnJ0Y2dyb3VwLmNvbSIsImlkIjo3NTcwMCwic2l0ZSI6Imh0dHA6XC9cLzIwLjEyNi4xMjEuMTEyXC9ucnRjIiwidXNlcm5hbWUiOiJhYmR1bGxhaEBucnRjZ3JvdXAuY29tIiwidXNlcklkIjo3NTcwMCwib2xkVXNlcklkIjpudWxsLCJkaXNwbGF5X25hbWUiOiJBYmR1YWxsYWggdGVzdCIsInNlc3Npb25JZCI6Im9paGNuMmdrZXFpOWRxa25lZTRkbHVrMWJnIiwiaXNzIjoiYXBwQHNlY3VyZS5ucnRjZnJlc2guY29tIiwic3ViIjoiYXBwQHNlY3VyZS5ucnRjZnJlc2guY29tIiwiZXhwIjoxNjUyODU0MTUxLCJraW5kIjoiYXV0aC10b2tlbiIsInJvbGVzIjpbImN1c3RvbWVyIl0sImNvY2FydF9rZXkiOnsiY19rZXkiOiJja18xMGFiMDJiYTdjMDJlYmU1ZTliZmQwNjg4M2Q1MDc4NjQ0MTI0ZGMxIiwiY19zZWNyZXQiOiJjc19lODMwOWUwODFlYTZmNTkzNTE3MWYyMDE4OGZiZTUyNjliZDhmZTBlIn19.MSWyFCyu6D88dj2MhD7MrV9x1-L7MUnFS4WAKyc_ALo",
"oldUserId": null,
"displayName": "Abduallah test",
"roles": [
"customer"
],
"expiresIn": 1652854151
}
How can I make changes to the plugin code to achieve the above response??
I appreciate your efforts and support in advance.
Thanks a lot...
I have been using the Google API client in PHP for a project with google assistant where I need to post transaction updates.
See : https://developers.google.com/actions/transactions/dev-guide-physical-custom#6_send_order_updates
I use the server-to-server procedure to connect : https://developers.google.com/api-client-library/php/auth/service-accounts
I didn't found any support for Transactions or Actions. So I can't just call a service like the example. My goal is just to get the bearer token back and code the update based on the documentation of the transactions.
So I made this code :
$client = new Google_Client();
putenv('GOOGLE_APPLICATION_CREDENTIALS='.'path/to/file/');
$client->useApplicationDefaultCredentials();
$client->setApplicationName('Update_Orders_Test');
$client->setScopes(['https://www.googleapis.com/auth/actions.fulfillment.conversation']);
$auth = $client->authorize();
But with this code I can't get the bearer token in the $client object or the $auth object. But I do not have any error too. The path to the JSON file is correct, there is an error if the file doesn't exist.
Here is the client object :
{
"auth": null,
"http": {},
"cache": {},
"token": null,
"config": {
"application_name": "Update_Orders_Test",
"base_path": "https://www.googleapis.com",
"client_id": "",
"client_secret": "",
"redirect_uri": null,
"state": null,
"developer_key": "",
"use_application_default_credentials": true,
"signing_key": null,
"signing_algorithm": null,
"subject": null,
"hd": "",
"prompt": "",
"openid.realm": "",
"include_granted_scopes": null,
"login_hint": "",
"request_visible_actions": "",
"access_type": "online",
"approval_prompt": "auto",
"retry": [],
"cache_config": [],
"token_callback": null,
"jwt": null
},
"logger": null,
"deferExecution": false,
"requestedScopes": [
"https://www.googleapis.com/auth/actions.fulfillment.conversation"
]
}
As you can see the basic information are set but not the one relative to the json file.
Is there something I did wrong with this code ?
I working on a BotMan based Messenger chatbot. I set up everything, tried to test out, everything went fine, but I got stuck.
I wanted to send an image as a response from my bot to my Facebook profile. It sent the image, but after it I got stuck: It tries to send the message again and I see in nGrok, that I have an 500 error request from my webhook.
I tried the following:
comment out the code to debug
restart the webserver
restart nGrok and set up a new webhook with the new address
restart computer than do the earlier
Nothing is helped from the following. With other Facebook profile I can "speak" with it (I got the good responses for my test cases), but the first profile is stuck. How to "unstuck" it?
EDIT:
This is the object, what tries to send, but gains error 500:
{
"object": "page",
"entry": [
{
"id": "1718785685111526",
"time": 1518649220812,
"messaging": [
{
"sender": {
"id": "1718785685111526"
},
"recipient": {
"id": "1702775193145548"
},
"timestamp": 1518641306603,
"message": {
"is_echo": true,
"app_id": 813542108832080,
"mid": "mid.$cAAZBynpFHa9nx1ij61hlhNatNiJj",
"seq": 353844,
"attachments": [
{
"type": "image",
"payload": {
"url": "https://scontent-ort2-2.xx.fbcdn.net/v/t34.0-12/28001431_2003444363312322_578145807_n.jpg?_nc_ad=z-m&_nc_cid=0&oh=7088ad6e09a1c9851a967c8193ea3bf4&oe=5A871570"
}
}
]
}
}
]
}
]
}
I'm currently creating a Twitch notification web app in PHP.
For the moment, the authentication works fine :
Client wants use the app -> redirected on Twitch website to accept asked scopes -> redirected on my app website with a "code" parameter -> "code" sent by curl request -> response containing the accessToken.
I stored accessToken and client username in $_COOKIE and $_SESSION variable (set $_COOKIE doesn't work on all web browsers).
After that I have to check (in real-time ?) if the user has new followers. Certains web applications, as TNotifier, exists and do this very well... But I don't know how.
In the Twitch API, we have only for the follows request the possibility to list all of these followers. I thought directly i will have to make requests, again and again (with one second of delay), and compare the new request with the last one... But i think there 's an other way to make that ?
Here is the follows request :
curl -H 'Accept: application/vnd.twitchtv.v2+json' \
-X GET https://api.twitch.tv/kraken/channels/test_user1/follows
And the JSON response :
{
"_links": {
"next": "https://api.twitch.tv/kraken/channels/test_user1/follows?limit=25&offset=25",
"self": "https://api.twitch.tv/kraken/channels/test_user1/follows?limit=25&offset=0"
},
"follows": [
{
"_links": {
"self": "https://api.twitch.tv/kraken/users/test_user2/follows/channels/test_user1"
},
"user": {
"_links": {
"self": "https://api.twitch.tv/kraken/users/test_user2"
},
"staff": false,
"logo": null,
"display_name": "test_user2",
"created_at": "2013-02-06T21:21:57Z",
"updated_at": "2013-02-13T20:59:42Z",
"_id": 40091581,
"name": "test_user2"
}
},
...
]
}
Here is my code, but still thinking a better way exists...
$uknown=""; //to initialize my loop function.
comparaison($uknown);
function comparaison($u){
$options = array(
'http' => array(
'header' => 'Accept: application/vnd.twitchtv.v2+json',
'method' => 'GET',
)
);
$context = stream_context_create($options);
$result = file_get_contents('https://api.twitch.tv/kraken/channels/test_user1/follows', false, $context);
$decode_result = json_decode($result, true);
$follow=$decode_result['follows'][0];
$user=$follow['user'];
$last_follower=$user['display_name'];
if($last_follower != $u){
haveANewFollower($last_follower);
}
comparaison($last_follower);
}
Is it possible TNotifier use another way to check new followers ?
It's the only way, as there's no push way to do followers, so you have to rely on pulling. For subscribers there would be the possibility to listen for chat messages for new subscribers, but as this does not work for followers, you can only rely on the pull method using the kraken api.