Unificationengine not working with instagram - instagram

When I am sharing a message on instagram by UnificationEngine then I am getting this error:
Exception in UEUser.php line 74: The password you entered is incorrect. Please try again in UEUser.php line 74
at UEUser->add_connection('instagramBoard', 'instagram', '4544942713.7da612b.4de7a5a78fb0491dba2b27a60dc1749d') i
My Code is:
$app = new UEApp("APP_KEY","APP_SECRATE");
$user = new UEUser("USER_KEY", "USER_SECREATE");
$con = $access_token ."#instagram.com/?username=rajneesh8239&password=testing1";
$connection = $user->add_connection("instagramBoard", "instagram", $con);
$options = array(
"receivers" => array(
array(
"name"=> "Me"
)
),
"message"=>array(
"subject"=>"Transparentcom testing fine",
"body"=> "",
"image"=> '',
"link"=>array(
"uri"=> '',
"description"=> "",
"title"=>"Click here for view"
)
)
);
//Send the message and get their uris
$uris = $connection->send_message($options);
CURL error:
vagrant#homestead:~/Code/laravel$ curl -XPOST https://apiv2.unificationengine.c
om/v2/user/create -u 590f402bd2a043f98823eb1940b2ab:a62c855ae17b5cacb355abfbcc3a93 --data '{}'
{"status":200,"info":"200 OK","uri":"user://0e4946b0-9e60-4e0f-b54-f4e39ab5b0b:0490d37c-e284-422e-b8de-00b5f81ff81#"}
vagrant#homestead:~/Code/laravel$ curl -XPOST https://apiv2.unificationengine.c
om/v2/connection/add -u 0e494b0-9e-4e0f-ab54-f4eab53b0b:04937c-e284-422e-b8de-003b5f81ff81 --data '{"uri":"instagram://4544942713.7da612b.4de7a5a78fb0491dba2b327a60dc1749d#instagram.com", "name":"instagram"}'
{"status":500,"info":"incorrect Password"}

Please use this code like this way, You need to just change this line like this way.
$con = $access_token."#instagram.com/?username=rajneesh8239&password=testing1";
$connection = $user->add_connection("instagramBoard", "instagram", $con);
Please check with code

Related

Device code flow: Microsoft.Identity.Client.MsalServiceException: AADSTS70011: The provided value for the input parameter 'scope' is not valid

This question is not a duplicate of AADSTS70011: The provided value for the input parameter 'scope' is not valid because that post didn't solve my problem.
This is the code:
using Microsoft.Identity.Client;
var tenantId = "common";
var clientId = "475c75f3-9fdc-4d23-8956-104342a43740";
var apiUrl = "https://graph.microsoft.com";
var app = PublicClientApplicationBuilder.CreateWithApplicationOptions(
new PublicClientApplicationOptions{
TenantId="common",
ClientId=clientId
}
)
.WithRedirectUri("http://localhost")
.Build();
string[] scopes = new string[] {$"{apiUrl}/.default"};
var result = await app.AcquireTokenWithDeviceCode(
scopes,
deviceCodeResult =>
{
Console.WriteLine(deviceCodeResult.Message);
return Task.FromResult(0);
}
).ExecuteAsync();
Console.WriteLine(result.AccessToken);
This is the error message that I get:
Unhandled exception. MSAL.NetCore.4.44.0.0.MsalServiceException:
ErrorCode: invalid_scope
Microsoft.Identity.Client.MsalServiceException: AADSTS70011: The provided value for the input parameter 'scope' is not valid. One or more scopes in 'https://graph.microsoft.com/.default offline_access profile openid' are not compatible with each other.
Trace ID: 977837bb-49bb-448a-990f-f640ee518500
Correlation ID: f6483ab1-e0be-43b0-8859-086b28ac6ea2
Timestamp: 2022-06-12 00:26:35Z
at Microsoft.Identity.Client.OAuth2.OAuth2Client.ThrowServerException(HttpResponse response, RequestContext requestContext)
at Microsoft.Identity.Client.OAuth2.OAuth2Client.CreateResponse[T](HttpResponse response, RequestContext requestContext)
at Microsoft.Identity.Client.OAuth2.OAuth2Client.ExecuteRequestAsync[T](Uri endPoint, HttpMethod method, RequestContext requestContext, Boolean expectErrorsOn200OK, Boolean addCommonHeaders, Func`2 onBeforePostRequestData)
at Microsoft.Identity.Client.OAuth2.OAuth2Client.GetTokenAsync(Uri endPoint, RequestContext requestContext, Boolean addCommonHeaders, Func`2 onBeforePostRequestHandler)
at Microsoft.Identity.Client.OAuth2.TokenClient.SendHttpAndClearTelemetryAsync(String tokenEndpoint, ICoreLogger logger)
at Microsoft.Identity.Client.OAuth2.TokenClient.SendHttpAndClearTelemetryAsync(String tokenEndpoint, ICoreLogger logger)
at Microsoft.Identity.Client.OAuth2.TokenClient.SendTokenRequestAsync(IDictionary`2 additionalBodyParameters, String scopeOverride, String tokenEndpointOverride, CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.DeviceCodeRequest.WaitForTokenResponseAsync(DeviceCodeResult deviceCodeResult, CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.DeviceCodeRequest.WaitForTokenResponseAsync(DeviceCodeResult deviceCodeResult, CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.DeviceCodeRequest.ExecuteAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters, AcquireTokenWithDeviceCodeParameters deviceCodeParameters, CancellationToken cancellationToken)
at Program.<Main>$(String[] args) in /home/adrian/azure/Program.cs:line 16
at Program.<Main>(String[] args)
StatusCode: 400
According to this documentation, the device code flow can be reproduced with this script:
TENANT_ID='common'
CLIENT_ID='475c75f3-9fdc-4d23-8956-104342a43740'
output=$(
curl -s https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/devicecode \
-X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "client_id=${CLIENT_ID}&scope=user.read%20openid%20profile"
)
echo "URL: $(jq -r '.verification_uri' <<<$output)"
echo "CODE: $(jq -r '.user_code' <<<$output)"
read
output=$(
curl -s https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token \
-X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code&client_id=${CLIENT_ID}&device_code=$(jq -r '.device_code' <<<$output)"
)
curl -s https://graph.microsoft.com/v1.0/me \
-H "Authorization: Bearer $(jq -r '.access_token' <<<$output)" | jq
However, for some reason when I execute the script I don't get any errors. Why?
EDIT: I thought I was using the .default scope in the script too, my bad. This is the updated code, which now returns yet another different error:
TENANT_ID='common'
CLIENT_ID='475c75f3-9fdc-4d23-8956-104342a43740'
output=$(
curl -s https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/devicecode \
-X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "client_id=${CLIENT_ID}&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default"
)
echo "URL: $(jq -r '.verification_uri' <<<$output)"
echo "CODE: $(jq -r '.user_code' <<<$output)"
read
curl -s https://login.microsoftonline.com/${TENANT_ID}/oauth2/v2.0/token \
-X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code&client_id=${CLIENT_ID}&device_code=$(jq -r '.device_code' <<<$output)"
and this is the error I get:
{
"error": "invalid_scope",
"error_description": "AADSTS70011: The provided value for the input parameter 'scope' is not valid. One or more scopes in 'https://graph.microsoft.com/.default' are not compatible with each other.\r\nTrace ID: 9d5809b7-32ad-4c18-a8d8-4ac49a439100\r\nCorrelation ID: eb10447d-fce6-4a33-b669-c62924f4e08a\r\nTimestamp: 2022-06-12 09:59:54Z",
"error_codes": [
70011
],
"timestamp": "2022-06-12 09:59:54Z",
"trace_id": "9d5809b7-32ad-4c18-a8d8-4ac49a439100",
"correlation_id": "eb10447d-fce6-4a33-b669-c62924f4e08a"
}

BASH CURL pass json data for POST request

im trying try to POST a request in a BASH script but somehow, my json data cant be find bellow is my code.
header=$(curl -sb -H "Accept: application/json" "http://localhost:4040/api/tunnels")
# this is json format
tunnels=`echo "$header"`
echo "{'token':'xoxp-token-key','channel':'hybridteam','appname':'Server Unit', 'data': ${tunnels}}"
header2=$(curl -H "Content-type: application/json" -H "Accept: application/json" -sb -d "{'token':'token-key-here','channel':'hybridteam-ngrok','appname':'This is testing PC', 'data': ${tunnels}}" -X POST "https://localhost:8080")
success=`echo "$header2"`
echo $success
And my Server gets the data like this
$data = json_decode(isset($_POST['data'])? $_POST['data'] : $_GET['data']);
$token = isset($_POST['token'])? $_POST['token'] : $_GET['token'];
$channel = isset($_POST['channel'])? $_POST['channel'] : $_GET['channel'];
BUT on my server I keep getting this response
<br /> <b>Notice</b>: Undefined index: data in <b>C://xampp/htdocs/server/index.php</b> on line <b>30</b><br /> <br /> <b>Notice</b>: Undefined index: token in <b>C://xampp/htdocs/server/index.php</b> on line <b>31</b><br /> <br /> <b>Notice</b>: Undefined index: channel in <b>C://xampp/htdocs/server/index.php</b> on line <b>32</b><br />
Pls Im new to bash scripting, need your help.
Thanks.
json supports double quotes
curl -H "Content-type: application/json" \
-H "Accept: application/json" -sb \
-d "{\"token\":\"token-key-here\",\"channel\":\"hybridteam-ngrok\",\"appname\":\"This is testing PC\", \"data\": ${tunnels}}" \
-X POST "https://localhost:8080"
and you need to read raw POST body and convert it either into object or to array.
$raw = file_get_contents("php://input");
$data = json_decode($raw,true);
$token = isset($data['token'])? $data['token'] : null;
$channel = isset($data['channel'])? $data['channel'] : null;

parse error: Invalid numeric literal at line 1, column 8

I am trying to get a token to some site by using curl. It looks like request is done correctly because I have to wait a bit for response however something is during deserialization because I always got error: parse error: Invalid numeric literal at line 1, column 8
This is how script looks like:
TOKEN=$(curl --request POST \
--url 'https://${DOMAIN_NAME}/getmy/token' \
--header 'content-type: application/json' \
--data '{"grant_type":"password", "username":"${USER_EMAIL}",
"password":"${USER_PASSWORD}",
"audience":"https://localhost:8443/my-composite-service", "scope":"openid
email test:read test:write", "client_id": "${CLIENT_ID}",
"client_secret": "${CLIENT_SECRET}"}' -s | jq -r .access_token)
Is it because of jq?
What is more I am sure that env variables are there, even with hard coded values the same error will be thrown.
Thank you in advance
Some hints:
Do not put everything in one line, make it readable instead.
Structure your code with functions.
Do error handling.
Use Bash's debugging functionality.
Do not build JSON with string concatenation, use JQ instead, because only JQ quotes JSON data correctly. A password may contain quoting characters.
An example:
set -eu
set -x
USER_EMAIL="user#domain.org"
USER_PASSWORD="password"
CLIENT_ID="id"
CLIENT_SECRET="secret"
DOMAIN_NAME="domain.org"
data()
{
local template='
{
"grant_type": "password",
"username": $username,
"password": $password,
"audience": "https://localhost:8443/my-composite-service",
"scope": "openid email test:read test:write",
"client_id": $client_id,
"client_secret": $client_secret
}'
if jq <<<null -c \
--arg username "${USER_EMAIL}" \
--arg password "${USER_PASSWORD}" \
--arg client_id "${CLIENT_ID}" \
--arg client_secret "${CLIENT_SECRET}" \
"$template"
then
return
else
printf "ERROR: Can not format request data." >&2
exit 1
fi
}
post()
{
if curl --request POST \
--url 'https://${DOMAIN_NAME}/getmy/token' \
--header 'content-type: application/json' \
--data "$1" \
-s
then
return
else
printf "ERROR: Can not send post request." >&2
exit 1
fi
}
token()
{
if jq -r .access_token
then
return
else
printf "ERROR: Can not parse JSON response." >&2
exit 1
fi
}
TOKEN="$(post "$(data)" | token)"

how to use the simple-oauth2 library to make request application/x-www-form-urlencoded?

i have some code which perfectly work through mac terminal and giving me token from website
curl -XPOST "https://link.com/oauth/access_token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: 1.0" \
--data-urlencode "grant_type=client_credentials" \
--data-urlencode "client_id=myawesomeapp" \
--data-urlencode "client_secret=abc123" \
--data-urlencode "scope=read write"
I want to do request through nodejs without curl request. website giving link on npm library simple-oauth2, but my code does not work.
my not working version of this
const credentials = {
client: {
id: 'myawesomeapp',
secret: 'abc123'
},
auth: {
tokenHost: 'https://link.com',
tokenPath: '/oauth/access_token'
},
http: {
'headers.authorization': 'headers.Accept = application/x-www-form-urlencoded'
}
};
oauth2 = oauth2.create(credentials);
oauth2.accessToken.create()
If it's an x-www-form-urlencoded content type, you'll probably need to also update the authorisation method in your options to form (its default is header). I.e.
const credentials = {
/*
your existing config
*/
options: {
authorizationMethod: 'body'
}
}
Hopefully that should do the trick...

Zingchart PHP wrapper issue

I am attempting to set up Zingchart using the PHP wrapper module.
Server:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
Running as a VM under VMWare
I am receiving an error with the example code when calling the ZC->connect method.
Thus:
<HTML>
<HEAD>
<script src="zingchart.min.js"></script>
</HEAD>
<BODY>
<h3>Simple Bar Chart (Database)</h3>
<div id="myChart"></div>
<?php
include 'zc.php';
use ZingChart\PHPWrapper\ZC;
$servername = "localhost";
$username = "nasuser";
$password = "password";
$db = "nas";
$myQuery = "SELECT run_time, time_total from stats";
// ################################ CHART 1 ################################
// This chart will use data pulled from our database
$zc = new ZC("myChart", "bar");
$zc->connect($servername, "3306", $username, $password, $db);
$data = $zc->query($myQuery, true);
$zc->closeConnection();
$zc->setSeriesData($data);
$zc->setSeriesText($zc->getFieldNames());
$zc->render();
?>
</BODY></HTML>
Error:
# php index.php
PHP Fatal error: Uncaught Error: Class 'ZingChart\PHPWrapper\mysqli' not found in /var/www/html/zc.php:69
Stack trace:
#0 /var/www/html/index.php(22): ZingChart\PHPWrapper\ZC->connect('localhost', '3306', 'nasuser', 'password', 'nas')
Line 69 is:
$this->mysqli = new mysqli($host, $username, $password, $dbName, $port);
Running:
# php -m | grep -i mysql
mysqli
mysqlnd
pdo_mysql
Seems to indicate that I have the relevant packages installed. Indeed, if I attempt a normal PHP connection it works:
<?php
$servername = "localhost";
$username = "nasuser";
$password = "password";
$dbname = "nas";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * from stats limit 10;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["stat_id"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
Output:
# php db.php
id: 1<br>id: 2<br>id: 3<br>id: 4<br>id: 5<br>id: 6<br>id: 7<br>id: 8<br>id: 9<br>id: 10<br>
Any ideas?
Thanks.
I've encountered the same problem!
There's kind of problem with import on the mysqli.
I changed the
$this->mysqli = new mysqli($host, $username, $password, $dbName, $port);
from ZC.php to
$this->mysqli = new \mysqli($host,$username,$password, $dbName, $port);
and worked.

Resources