Linkedin Oauth invalid_signature - zend-framework

Getting following error when trying to send oauth request to linkedin. Tried changing all configuration settings on Linkedin Developer page, without luck.
Zend_Http_Response Object
(
[version:protected] => 1.1
[code:protected] => 401
[message:protected] => Unauthorized
[headers:protected] => Array
(
[Server] => Apache-Coyote/1.1
[Www-authenticate] => OAuth realm="https%3A%2F%2Fapi.linkedin.com", oauth_problem="signature_invalid", oauth_problem_advice="com.linkedin.security.auth.pub.LoginDeniedInvalidAuthTokenException%20while%20obtaining%20request%20token%20for%20%3APOST%26https%253A%252F%252Fapi.linkedin.com%252Fuas%252Foauth%252FrequestToken%26oauth_callback%253Dhttp%25253A%25252F%25252Fsocialnucleus.org%25252Fwall%25252Flinkedin%25252Findex%25252Fformat%25252Fsmoothbox%25252Ftask%25252Fstream%2526oauth_consumer_key%253D753ndm4jkq5ug9%2526oauth_nonce%253D296db6c938b6b3a7af93bd01c37e4d5f%2526oauth_signature_method%253DHMAC-SHA1%2526oauth_timestamp%253D1409219193%2526oauth_version%253D1.0%2526scope%253Drw_nus%0AOAU%3A753ndm4jkq5ug9%7C%2A01%7C%2A01%7C%2A01%3A1409219193%3AKNkpSGf5VSdXkeLYVO0xW%2Fr6N%2BE%3D"
[Content-type] => application/x-www-form-urlencoded;charset=UTF-8
[Content-encoding] => gzip
[Vary] => Accept-Encoding
[Date] => Thu, 28 Aug 2014 09:47:13 GMT
[X-fs-uuid] => 2ad6973e6d8d8e13004a6ed9fc2a0000
[X-li-uuid] => KtaXPm2NjhMASm7Z/CoAAA==
[X-li-fabric] => PROD-ELA4
[Transfer-encoding] => chunked
[Connection] => keep-alive
[X-li-pop] => PROD-ELA4
[Set-cookie] => lidc="b=LB37:g=108:u=1:i=1409219233:t=1409305633:s=132873074"; Expires=Fri, 29 Aug 2014 09:47:13 GMT; domain=.linkedin.com; Path=/
)
[body:protected] => 1aa...
)

Start with the guide to debug API calls: https://developer.linkedin.com/documents/debugging-api-calls
It seems that the signature isn't being generated correctly. Use OAuth Test Console: https://developer.linkedin.com/oauth-test-console to generate the signature and the request URL.

Related

Sendgrid email api showing unauthorized error

I am trying to send email through SENDGRID API from
https://packagist.org/packages/sendgrid/sendgrid
I am using "Hello Email" code from above link
But when I try to run email this is what I am getting
Array
(
[0] => HTTP/1.1 401 UNAUTHORIZED
[1] => Server: nginx
[2] => Date: Wed, 03 Apr 2019 04:33:59 GMT
[3] => Content-Type: application/json
[4] => Content-Length: 62
[5] => Connection: keep-alive
[6] => Access-Control-Allow-Methods: HEAD, GET, OPTIONS, DELETE
[7] => Access-Control-Max-Age: 21600
[8] => Access-Control-Expose-Headers: Link, Location
[9] => Access-Control-Allow-Origin: *
[10] => Access-Control-Allow-Headers: AUTHORIZATION, Content-Type, On-behalf-of, x-sg-elas-acl, X-Recaptcha, X-Request-Source
[11] => Content-Security-Policy: default-src https://api.sendgrid.com; frame-src 'none'; object-src 'none'
[12] => X-Content-Type-Options: nosniff
[13] => Strict-Transport-Security: max-age=31536000
[14] =>
[15] =>
)
{"errors":[{"field":null,"message":"authorization required"}]}
Even I uploaded on the live server, but still getting same, tried to create 2,3 more API keys with full access but getting the same issue.
Please help me...

Dead letters using Akka HTTP client and Akka Streams

I'm trying to use Akka HTTP and Akka Streams to run a scraper. I'm starting with a bunch of index pages, parsing links out of them, then fetching each link and parsing that page, to return a bunch of individual links. So, like this:
fetch-top-level-page -> list-of-links-to-child-pages -> fetch-child-page -> list-of-links-in-child-page
My problem is that I'm not even able to fetch a single page. Each top-level URL I try to fetch results in a dead letter, and nothing ever makes it further down the pipeline.
In this sample code, all I'm trying to do is send HttpRequest into the pool to be transformed into an HttpResponse, and prove that it worked by printing stuff to the screen.
implicit val system = ActorSystem("scraper")
implicit val ec = system.dispatcher
implicit val settings = system.settings
implicit val materializer = ActorMaterializer()
val requests = List(HttpRequest(...), HttpRequest(...))
val poolClientFlow = Http().superPool[Promise[HttpResponse]](settings = ConnectionPoolSettings(system).withMaxConnections(10))
Source(requests)
.map (req => { println("-", req); req}) // this part runs fine
.via(poolClientFlow)
.map(resp => {println("|", resp); resp}) // this never runs
.toMat(Sink.foreach { p => println(p) })(Keep.both)
.run()
Here's what I get:
(-,(HttpRequest(...),Future(<not completed>)))
(-,(HttpRequest(...),Future(<not completed>)))
[INFO] [03/07/2018 15:10:03.681] [scraper-akka.actor.default-dispatcher-5] [akka://scraper/user/pool-master] Message [akka.http.impl.engine.client.PoolMasterActor$SendRequest] without sender to Actor[akka://scraper/user/pool-master#1333123700] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [03/07/2018 15:10:03.683] [scraper-akka.actor.default-dispatcher-5] [akka://scraper/user/pool-master] Message [akka.http.impl.engine.client.PoolMasterActor$SendRequest] without sender to Actor[akka://scraper/user/pool-master#1333123700] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
I'm new to Akka and obviously making some basic error, since this seems to be the exact use case that Akka, Akka Streams, and Akka HTTP were built for.
Any ideas?
Unable to reproduce with Akka HTTP 10.1.0-RC2 and Akka Streams 2.5.11. The following works:
val requests = List((HttpRequest(uri = "http://akka.io"), Promise[HttpResponse]()),
(HttpRequest(uri = "http://www.yahoo.com"), Promise[HttpResponse]()))
val poolClientFlow =
Http().superPool[Promise[HttpResponse]](settings = ConnectionPoolSettings(system).withMaxConnections(10)
Source(requests)
.map { req => println("-", req); req }
.via(poolClientFlow)
.map { resp => println("|", resp); resp }
.toMat(Sink.foreach(println))(Keep.both)
.run()
// The following is printed:
// (-,(HttpRequest(HttpMethod(GET),http://akka.io,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)),Future()))
// (-,(HttpRequest(HttpMethod(GET),http://www.yahoo.com,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)),Future()))
// (|,(Success(HttpResponse(301 Moved Permanently,List(Date: Thu, 08 Mar 2018 14:33:46 GMT, Connection: keep-alive, Cache-Control: max-age=3600, Expires: Thu, 08 Mar 2018 15:33:46 GMT, Location: https://akka.io/, Server: cloudflare, CF-RAY: 3f8604d386979cf6-AMS),HttpEntity.Chunked(application/octet-stream),HttpProtocol(HTTP/1.1))),Future()))
// (Success(HttpResponse(301 Moved Permanently,List(Date: Thu, 08 Mar 2018 14:33:46 GMT, Connection: keep-alive, Cache-Control: max-age=3600, Expires: Thu, 08 Mar 2018 15:33:46 GMT, Location: https://akka.io/, Server: cloudflare, CF-RAY: 3f8604d386979cf6-AMS),HttpEntity.Chunked(application/octet-stream),HttpProtocol(HTTP/1.1))),Future())
// (|,(Success(HttpResponse(301 Moved Permanently,List(Date: Thu, 08 Mar 2018 14:33:46 GMT, Connection: keep-alive, Via: http/1.1 media-router-fp6.prod.media.ir2.yahoo.com (ApacheTrafficServer [c s f ]), Server: ATS, Cache-Control: no-store, no-cache, Content-Language: en, X-Frame-Options: SAMEORIGIN, Location: https://www.yahoo.com/),HttpEntity.Strict(text/html,ByteString(114, 101, 100, 105, 114, 101, 99, 116)),HttpProtocol(HTTP/1.1))),Future()))
// (Success(HttpResponse(301 Moved Permanently,List(Date: Thu, 08 Mar 2018 14:33:46 GMT, Connection: keep-alive, Via: http/1.1 media-router-fp6.prod.media.ir2.yahoo.com (ApacheTrafficServer [c s f ]), Server: ATS, Cache-Control: no-store, no-cache, Content-Language: en, X-Frame-Options: SAMEORIGIN, Location: https://www.yahoo.com/),HttpEntity.Strict(text/html,ByteString(114, 101, 100, 105, 114, 101, 99, 116)),HttpProtocol(HTTP/1.1))),Future())
// [WARN] [03/08/2018 14:46:31.003] [scraper-akka.actor.default-dispatcher-4] [scraper/Pool(shared->http://akka.io:80)] [0 (WaitingForResponseEntitySubscription)] Response entity was not subscribed after 1 second. Make sure to read the response entity body or call `discardBytes()` on it. GET / Empty -> 301 Moved Permanently Chunked
Probably a better approach is something like this (note the call to discardEntityBytes()):
Source(requests)
.map { req => println("-", req); req }
.via(poolClientFlow)
.map { resp => println("|", resp); resp }
.toMat(Sink.foreach({
case ((util.Success(resp), p)) =>
resp.discardEntityBytes()
p.success(resp)
case ((util.Failure(e), p)) => p.failure(e)
}))(Keep.both)
.run()
// The following is printed:
// (-,(HttpRequest(HttpMethod(GET),http://akka.io,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)),Future()))
// (-,(HttpRequest(HttpMethod(GET),http://www.yahoo.com,List(),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1)),Future()))
// (|,(Success(HttpResponse(301 Moved Permanently,List(Date: Thu, 08 Mar 2018 14:38:32 GMT, Connection: keep-alive, Via: http/1.1 media-router-fp21.prod.media.ir2.yahoo.com (ApacheTrafficServer [c s f ]), Server: ATS, Cache-Control: no-store, no-cache, Content-Language: en, X-Frame-Options: SAMEORIGIN, Location: https://www.yahoo.com/),HttpEntity.Strict(text/html,ByteString(114, 101, 100, 105, 114, 101, 99, 116)),HttpProtocol(HTTP/1.1))),Future()))
// (|,(Success(HttpResponse(301 Moved Permanently,List(Date: Thu, 08 Mar 2018 14:38:32 GMT, Connection: keep-alive, Cache-Control: max-age=3600, Expires: Thu, 08 Mar 2018 15:38:32 GMT, Location: https://akka.io/, Server: cloudflare, CF-RAY: 3f860bca84a32ba6-AMS),HttpEntity.Chunked(application/octet-stream),HttpProtocol(HTTP/1.1))),Future()))

Paypal Adaptive

I am using paypal adaptive. Its working if i use sandbox account. But paypal is not working if i use live account.
Paypal throw error as below.
Array
(Server: Apache
X-EBAY-SOA-REQUEST-ID: 15674515-0c90-a115-45a6-9f3dfffd5017!AdaptivePayments!10.17.84.90![]
X-PAYPAL-SERVICE-VERSION: 1.0.0
X-PAYPAL-SERVICE-NAME: {http://svcs.paypal.com/types/ap}AdaptivePayments
X-PAYPAL-API-RC: 580029
X-EBAY-SOA-RESPONSE-DATA-FORMAT: NV
X-PAYPAL-OPERATION-NAME: Preapproval
CACHE-CONTROL: no-cache
X-PAYPAL-ERROR-RESPONSE: TRUE
X-EBAY-SOA-MESSAGE-PROTOCOL: NONE
Vary: Accept-Encoding
HTTP_X_PP_AZ_LOCATOR: dcg12.slc
Paypal-Debug-Id: 29d4c08e5ad57
Set-Cookie: X-PP-SILOVER] => name=LIVE6.APIT.1&silo_version=880&app=adaptivepaymentspartaweb_api3t&TIME=3709250391&HTTP_X_PP_AZ_LOCATOR=dcg12.slc;
Expires=Wed, 10 Aug 2016 12:28:21 GMT; domain=.paypal.com; path=/;
Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache
Connection: close
Content-Type: text/plain;charset=UTF-8
In this error, its showing like missing some subscription parameter. But I could not find what parameter is missing. Since its working correctly in sandbox.
responseEnvelope.timestamp=2016-08-10T04:58:21.486-07:00
[responseEnvelope.ack] => Failure
[responseEnvelope.correlationId] => 29d4c08e5ad57
[responseEnvelope.build] => 24003818
[error(0).errorId] => 580029
[error(0).domain] => PLATFORM
[error(0).subdomain] => Application
[error(0).severity] => Error
[error(0).category] => Application
[error(0).message] => One of the required parameters for subscription is missing
[error(0).parameter(0)] => Subscription
)
Kindly check and give me the solution.

YII2 DOC-2.0: RESTFUL POST example return invalid json

When I use command in http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html:
curl -i -H "Accept:application/json" -H "Content-Type:application/json" -XPOST "my api path/users" -d '{"username": "testuser", "email": "user#123.com"}'
it returns:
HTTP/1.1 400 Bad Request
Date: Tue, 01 Mar 2016 06:51:03 GMT
Server: Apache/2.4.4 (Win32) PHP/5.6.9
X-Powered-By: PHP/5.6.9
Vary: Accept-Encoding
Content-Length: 148
Connection: close
Content-Type: application/json; charset=UTF-8
{"name":"Bad Request","message":"Invalid JSON data in request body: Syntax error
.","code":0,"status":400,"type":"yii\\web\\BadRequestHttpException"}curl: (6) Co
uld not resolve host: testuser,
curl: (6) Could not resolve host: email
curl: (3) [globbing] unmatched close brace/bracket at pos 13
Check your behavior method :
public function behaviors()
{
return [
[
'class' => 'yii\filters\ContentNegotiator',
'only' => ['index', 'view','create'],
'formats' => ['application/json' => Response::FORMAT_JSON,],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'index'=>['get'],
'view'=>['get'],
'create'=>['post'],
'update'=>['post'],
'delete' => ['delete'],
'deleteall'=>['post'],
],
],
];
}
I try the same with POSTMAN .If you are sending raw data then remove single quote before and after your data. like {"usename":"sdasda"...}

Why it returns 302 and no error message returns with `If` in `Menu`?

Lift code in Boot.scala:
Menu.i("Topic") / "topic" >> If(() => false, "myerror")
From the document of If:
/**
* If the test returns True, the page can be accessed, otherwise,
* the result of FailMsg will be sent as a response to the browser.
* If the Loc cannot be accessed, it will not be displayed in menus.
*
* #param test -- the function that tests access to the page
* #param failMsg -- what to return the the browser (e.g., 304, etc.) if
* the page is accessed.
*/
case class If(test: () => Boolean, failMsg: FailMsg) extends AnyLocParam
It says: otherwise, the result of FailMsg will be sent as a response to the browser. So I expect it returns a http code of 5xx with error message myerror, but it not, it redirects to the index page / instead.
And with curl:
➜ ~ curl http://localhost:8080/topic -I
HTTP/1.1 302 Found
Set-Cookie: JSESSIONID=5gqkx8azu8gh1u3avyjds3wl;Path=/
Location: /
Expires: Tue, 16 Jul 2013 05:18:02 GMT
Content-Length: 0
Cache-Control: no-cache, private, no-store
Content-Type: text/plain
Pragma: no-cache
Date: Tue, 16 Jul 2013 05:18:02 GMT
X-Lift-Version: 2.5
Server: Jetty(8.1.7.v20120910)
Why it returns 302? And where is my error message myerror?
The reason you're seeing a redirect is that there's an implicit conversion from a String to a redirect to / (by default) with a Lift error notice set.
The string is used as the value of the error notice, which you can see displayed if you have Lift notices included on the page. It looks like the implicit is called strToFailMsg.
The recipe Access Restriction by HTTP Header in the Lift Cookbook touches on this briefly.
Menu.i("Topic") / "topic" >> If(() => false, RedirectResponse("/"))
What Lift version are you using?
In both Lift 2.4 and Lift 2.5, FailMsg is a alias of () ⇒ LiftResponse, so just simply provide it with NotFoundResponse("myerror") should work.
Menu.i("Topic") / "topic" >> If(() => false, () => net.liftweb.http.NotFoundResponse("myerror"))