My company has a WordPress-based intranet and we use Office365. I am hoping to hook into the graph as a global application (without explicit user consent) to grab data. I've gotten all of it working, but am having trouble with the /users/user_name/calendarview endpoint.
I can get valid access tokens using the following:
$auth_request_body = http_build_query( array(
'grant_type' => 'client_credentials',
'client_id' => CLIENT_ID,
'client_secret' => SECRET_KEY,
'resource' => 'https://graph.microsoft.com/'
) );
$response = wp_remote_post( $url, array(
'body' => $auth_request_body
) );
$body = json_decode( wp_remote_retrieve_body( $response ) );
$token_type = $body->token_type;
$access_token = $body->access_token;
and can make several successful calls, for example to the https://graph.microsoft.com/v1/users/user_name endpoint or to the https://graph.microsoft.com/v1/groups/group_id endpoint, however when attempting to reach the https://graph.microsoft.com/v1/users/user_id/calendarview endpoint I get the following response:
[body] => {
"error": {
"code": "ErrorAccessDenied",
"message": "Access is denied. Check credentials and try again.",
"innerError": {
"request-id": request_id,
"date": "2018-08-08T21:57:50"
}
}
}
[response] => Array
(
[code] => 403
[message] => Forbidden
)
I am working on my local environment, and for testing purposes I have granted all application / delegated permissions to my local machine (I think .. I'm still not positive how to ensure that newly grated permissions take effect on my local machine).
Any thoughts here?
... Nevermind.
Apparently my newly delegated permissions simply hadn't taken effect yet. This method above DOES work for my scenario.
I think you should confirm whether to grant the appropriate permissions to the application.
Related
I have implemented PHP SDK for amazon pay and currently I am facing one error, When I click on amazon pay button then one popup will be open for asking login credentials for amazon and after logged in successfully then it will redirect to Address book and payment methods choose page and on that page I am facing this error and Json response that I am getting are as below.
AmazonPay\ResponseParser Object
(
[response] => Array
(
[Status] => 401
[ResponseBody] =>
Sender
AccessDenied
Access denied
11e659e5-6413-4f49-ab38-339472490e5c
)
)
{
"Error": {
"Type": "Sender",
"Code": "AccessDenied",
"Message": "Access denied"
},
"RequestID": "11e659e5-6413-4f49-ab38-339472490e5c",
"ResponseStatus": "401"
}
So please suggest to me if you are aware of this error.
Thanks in advance!
Please set proper country wise config settings on amazon pay configuration file. i.e If your country select UK based then amazon pay sandbox work with GBP and UK only and if you try with another region or currency then you will get this Access Denied error.
Also cross check Amazon Sandbox credentials with that you have set in your file and make sure all settings will be correct.
<?php
namespace AmazonPay;
$config = array(
'merchant_id' => 'YOUR_MERCHANT_ID',
'access_key' => 'YOUR_ACCESS_KEY',
'secret_key' => 'YOUR_SECRET_KEY',
'client_id' => 'YOUR_LOGIN_WITH_AMAZON_CLIENT_ID',
'region' => 'REGION',
'sandbox' => true);
$client = new Client($config);
// Also you can set the sandbox variable in the config() array of the Client class by
$client->setSandbox(true);
Click here to see full documentation for implement amazon pay payment gateway in your website.
Please, you need to set proper country config settings on amazon pay configuration file. for example, If you select Region is UK and Currency is GBP while registration on seller-central account then you have to set 'region' => 'uk' and 'currency'=> 'GBP' in amazon pay configuration file. if you add different region or currency details then you will get Access Denied error.
please..follow below code
<?php
namespace AmazonPay;
$config = array(
'merchant_id' => 'YOUR_MERCHANT_ID',
'access_key' => 'YOUR_ACCESS_KEY',
'secret_key' => 'YOUR_SECRET_KEY',
'client_id' => 'YOUR_LOGIN_WITH_AMAZON_CLIENT_ID',
'region' => 'uk', //set value here
'currency_code' => 'GBP' //set value here
'sandbox' => true);
$client = new Client($config);
Having difficulties authorizing php SoapClient with MS Dynamic Great Plains. I can connect through SoapUI. However, it only successfully connects on 3rd attempt. Also, the auth token progressively gets longer. See pastebin link below.
I made use of the following package (https://github.com/mlabrum/NTLMSoap) to setup a NTLM stream, but it doesn't seem to be sending a correct token. The token length is shorter than what is sent through SoapUI.
$wsdlUrl = 'http://example.org:48620/Metadata/Legacy/Full/DynamicsGP.wsdl';
$options = [
'ntlm_username' => 'Domain\username',
'ntlm_password' => 'password'
];
$soapClient = new \NTLMSoap\Client($wsdlUrl, $options);
$params = array(
criteria => array(
'ModifiedDate' => array(
'GreaterThan' => '2016-04-18',
'LessThan' => '2016-04-19'
)
),>
'context' => array(
'OrganizationKey' => array(
'type' => 'CompanyKey',
'Id' =
)
)
);
$soapClient->__setLocation('http://example.org:48620/DynamicsGPWebServices/DynamicsGPService.asmx');
$response = $soapClient->GetPurchaseOrderList(array($params));
I had to set use ___setLocation() because client was being forwarded to http://localmachine:48620/DynamicsGPWebServices/DynamicsGPService.asmx
I have been trying to get Charles Web Proxy to work to show the actual the request/response, buts its crapped out on me.
This is the SoapUI output. http://pastebin.com/7zg4E3qD
I've searched far and wide and have come up with little to nothing on this problem. I've made a module for my Yii app that crawls my website and gathers links to generate a sitemap, I've even made it so that it can run on a cron.
Now I've hit the wall with Google Webmaster Tools API and it's lack of information on how to implement it with OAuth2 for sitemap submission.
Every time I've tried to submit the sitemap I got this response back:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
I would very much appreciate any pointers in any direction.
Maybe this extension can help you:
http://www.yiiframework.com/extension/jgoogleapi/
I'm not sure which is the API for sitemaps and what are its methods but that extension would help you Login to google in "Service" mode that won't need your browser to interact with the login.
You should also before create your application in Google console and then create a service account user type for it.
A paste of my config file when using this extension with Google Analytics:
<?php
/*
* How to obtain a Service Account:
* https://developers.google.com/accounts/docs/OAuth2ServiceAccount
*
*
* (403) User does not have any Google Analytics account.
* http://stackoverflow.com/a/13167988/115050
*
*
*/
return array(
'class' => 'ext.JGoogleAPI.JGoogleAPI',
//Default authentication type to be used by the extension
'defaultAuthenticationType'=>'serviceAPI',
//Account type Authentication data
'serviceAPI' => array(
'clientId' => '...',
'clientEmail' => '...',
'keyFilePath' => dirname(__FILE__).'/../extensions/JGoogleAPI/keys/Analytics-a0e8e345f273.p12',
),
/*
//You can define one of the authentication types or both (for a Service Account or Web Application Account)
webAppAPI = array(
'clientId' => 'YOUR_WEB_APPLICATION_CLIENT_ID',
'clientEmail' => 'YOUR_WEB_APPLICATION_CLIENT_EMAIL',
'clientSecret' => 'YOUR_WEB_APPLICATION_CLIENT_SECRET',
'redirectUri' => 'YOUR_WEB_APPLICATION_REDIRECT_URI',
'javascriptOrigins' => 'YOUR_WEB_APPLICATION_JAVASCRIPT_ORIGINS',
),
*/
'simpleApiKey' => 'AIzaSyAx63Ht-0XmuLdp0-j9zVREKNsCyqXgeUA',
//Scopes needed to access the API data defined by authentication type
'scopes' => array(
'serviceAPI' => array(
'drive' => array(
'https://www.googleapis.com/auth/drive.file',
),
'Analytics'=>array(
'https://www.googleapis.com/auth/analytics.readonly',
),
),
'webappAPI' => array(
'drive' => array(
'https://www.googleapis.com/auth/drive.file',
),
),
),
//Use objects when retriving data from api if true or an array if false
'useObjects'=>false,
);
And how I'm using it:
$api = Yii::app()->JGoogleAPI->getService('Analytics');
$api->data_ga->get(...)
Your access code is invalid. Use refresh token to avoid getting error while authenticating google client.
use the below code:
$gClient->setAccessType("offline");// to get refresh token after expiration of access token
$gClient->setIncludeGrantedScopes(true);
I'm attempting to retrieve an access token from BigCommerce. I'm following the instructions on this page: https://developer.bigcommerce.com/apps/callback
When I try to retrieve the access token, I am getting an invalid scope error. Here's the code:
public function access_token_get(){
print_r($_GET);
$tokenUrl = "https://login.bigcommerce.com/oauth2/token";
$connection = new Connection();
$connection->setCipher('RC4-SHA');
$connection->verifyPeer(false);
$response = $connection->post($tokenUrl, array(
"client_id" => "123456",
"client_secret" => "123456",
"redirect_uri" => "https://my-registered-auth-callback.com/",
"grant_type" => "authorization_code",
"code" => urlencode($_GET['code']),
"scope" => urlencode($_GET['scope']),
"context" => urlencode($_GET['context'])
));
print_r($response);
print_r($connection->getLastError());
$token = $response->access_token;
print_r($token);
}
When this code runs, I get an empty $response. I added the getLastError() line to see what was going on, and it's outputting:
stdClass Object ( [error] => Invalid scope(s). )
These are the parameters output from the GET request:
Array ( [code] => 2idy1ozvee8s0ddlbg3jgquzgtr55gd [context] => stores/xxxxxx [scope] => store_v2_orders store_v2_products store_v2_customers store_v2_content store_v2_marketing store_v2_information_read_only users_basic_information )
Why would I be receiving this "invalid scopes" error? I also tried hardcoding a single scope to see if that works, for example, just doing "scope"=>"store_v2_orders", but when I do this, I get an error saying that the scope has not been granted by the user.
Looks like the issue was that I did not need to urlencode the code, scope, and context. Removing the urlencode function fixed the issue.
Just wondering if anyone knows why Amazon's AWS would be telling me "The X509 Certificate you provided does not exist in our records."
Here's the code I'm using...
$sqs = new AmazonSQS();
$queue_url = 'my_url';
$options = array(
'MaxNumberOfMessages' => 10,
);
$resp = $sqs->receive_message($queue_url, $options);
print_r($resp);
Here's the response I get...
[Type] => Sender
[Code] => InvalidClientTokenId
[Message] => The X509 Certificate you provided does not exist in our records.
[Detail] => CFSimpleXML Object
Here's the CFCredentials array I'm using inside config.inc.php...
'#default' => array(
'key' => 'my-key',
'secret' => 'my-secret',
'default_cache_config' => 'cache',
'certificate_authority' => FALSE
)
In order to use Amazon SQS, you have to specifically sign up for Amazon SQS ; it looks like you are not sign-up. You can do it by visiting this page and clicking the button labeled "Sign up for Amazon SQS".
The reason I was getting this error was because I am using MAMP PRO which doesn't have CURL installed with SSL. Only CURL.
So to get around this so I could test from my local machine was the below code. Note the "#" on the second line. I used this to suppress the warning that is given out by disable_ssl() method.
$s3 = new AmazonS3();
#$s3->disable_ssl();