401 Unauthorized Access while using Twilio's Programmable Chat - ios

I am trying to create an iOS chat application using Twilio's Programmable Chat.
I am able to retrieve the token from Twilio by passing device token and identity, but I am getting the 401 unauthorized Access while loading the channels(if any). I have checked my Twilio credentials
TWILIO_ACCOUNT_SID
TWILIO_AUTH_TOKEN
TWILIO_API_KEY
TWILIO_API_SECRET
TWILIO_IPM_SERVICE_SID
and all of them are assigned properly.
This is my response which I received from Twilio.
json = ["identity": ved, "token": eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJkNTNmZGFjZDlmMWUwODA0OGZjOGE3MDU5ZTAyYTg1Zi0xNDk4NjY5Mjc1IiwiZ3JhbnRzIjp7ImlkZW50aXR5IjoidmVkIiwiaXBfbWVzc2FnaW5nIjp7InNlcnZpY2Vfc2lkIjoiSVMwNjYxMWUwNzE4M2U0NmVkOWE5ZWM1Yzg4ZGFhZmViNCIsImVuZHBvaW50X2lkIjoiQ2hhdFNlcnZpY2U6dmVkOnVuZGVmaW5lZCJ9fSwiaWF0IjoxNDk4NjY5Mjc1LCJleHAiOjE0OTg2NzI4NzUsImlzcyI6ImQ1M2ZkYWNkOWYxZTA4MDQ4ZmM4YTcwNTllMDJhODVmIiwic3ViIjoiQUMwYjI4OWViMGUwNTc2ZGU0NDNhMTkzYzdkZjk4YTg4OCJ9.LfSUM3v70Am3d3me6BQn7NC3T6mPggD9cikjf52Qvk8]
For reference, I am getting the below stackTrace in the console.
2017-06-28 22:33:18.705 twiliochat[1252:52536] TNNotificationClient[2]: 0x7000047ea000 | 06/28/22:33:18.704 | WARNING | 7 | TNNotificationClient | onTwilsockError: 0 - Poco exception while connecting: I/O error: Bad socket descriptor
2017-06-28 22:34:07.682 twiliochat[1252:52530] TNTransportConnectingState[3]: 0x7000044d8000 | 06/28/22:34:07.680 | INFO | 9 | TNTransportConnectingState | Leaving state: Transport connecting
2017-06-28 22:34:07.682 twiliochat[1252:53398] TNTwilsockClient[4]: 0x700004143000 | 06/28/22:34:07.680 | DEBUG | 1 | TNTwilsockClient | onMessageReceived (226)
TWILSOCK V1.0 160
{"method":"close","id":"TM43a26b096fb040dca4751bef7ca17dec","payload_size":43,"payload_type":"application/json","status":{"code":401,"status":"Not authorized"}}
{"code":401,"status":"Authorization error"}
Few Notes to consider before answering this thread :
I have set up my server properly and I am doing ngrok also.
I am using node.js for server setup.

Twilio developer evangelist here.
It looks like you are using your auth token instead of your API Key when generating your access token.
Make sure you are instantiating the Access Token like this:
const accessToken = new AccessToken(
context.TWILIO_ACCOUNT_SID,
context.TWILIO_API_KEY,
context.TWILIO_API_SECRET
);
The API Key should start "SK..."
Just as a precaution, since your auth token has been exposed you should change that in your Twilio console.
Let me know if that helps at all.

Related

how openstacksdk get_port just through ip_address

How to get the special port information which only dependent on the ip-address field by openstacksdk API, like the result as the openstack-client tool show:
# openstack port list --fixed-ip ip-address=1.1.1.1
+-----+------+-------------+---------------------------------------+--------+
| ID | Name | MAC Address | Fixed IP Addresses | Status |
+-----+------+-------------+---------------------------------------+--------+
| f23 | | fa:*****:ad | ip_address='1.1.1.1', subnet_id='821' | ACTIVE |
+-----+------+-------------+---------------------------------------+--------+
I had try these methods, none work:
port = conn.network.get_port(openstack.network.v2.port.Port(fixed_ips=[{'subnet_id'" '821', 'ip_address': '1.1.1.1'}]))
err: openstack.exceptions.InvalidRequest: Request requires an ID but none was found
port = conn.network.ports(fixed_ips=[{'ip_address': '1.1.1.1'}])
err: openstack.exceptions.BadRequestException: BadRequestException: 400: Client Error for url: domain:9696/v2.0/ports?fixed_ips=ip_address, Invalid input for operation: 'ip_address' is not of the form <key>=[value].
port = conn.network.ports(fixed_ips=['1.1.1.1'])
err: penstack.exceptions.BadRequestException: BadRequestException: 400: Client Error for url: domain:9696/v2.0/ports?fixed_ips=1.1.1.1, Invalid input for operation: '1.1.1.1' is not of the form <key>=[value].
port = conn.network.ports(ip_address='1.1.1.1')
err: openstack.exceptions.BadRequestException: BadRequestException: 400: Client Error for url: https://gzi-ost.2980.com:9696/v2.0/ports?ip_address=1.1.1.1, ['ip_address'] is invalid attribute for filtering
Refer to these documentation: network.port-operations and openstack api list-ports-detail .
How could I achieve that? Thank you in advance.
One more thing, I couldn't know the port_id before, only know the fixed ip-address.
Obviously, my bad, the problem is that my request parameter has a wrong format data.
Solve it by import urllib to encode the request json data in Python 3.
conn.network.ports(fixed_ips=urllib.parse.urlencode({'ip_address': '1.1.1.1'}))
Returns: A generator of port objects.
or
conn.list_ports({'fixed_ips': urllib.parse.urlencode({'ip_address': '1.1.1.1'})})
Returns: A list of port munch.Munch.

GET https://api.storekit.itunes.apple.com/inApps/v1/history/{originalTransactionId} 404

when i called the apple api: https://api.storekit-sandbox.itunes.apple.com/inApps/v1/history/{originalTransactionId} or https://api.storekit.itunes.apple.com/inApps/v1/history/{originalTransactionId} , http response 404
and when i check the apple document https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history?language=objc , i found that,404 is(AccountNotFoundError | AccountNotFoundRetryableError | AppNotFoundError | AppNotFoundRetryableError | OriginalTransactionIdNotFoundError | OriginalTransactionIdNotFoundRetryableError)
but i only can see 404, not 404xxx ;
thanks for your help;
Is it possible that you have not replaced the {originalTransactionId} with the original transaction ID value provided by Apple during the purchase?
In StoreKit v1, upon a purchase, Apple will return your app a base64 encoded string of receipt data.
Your app will have to pass this string back to you backend service.
Later on, from your backend, you can invoke /verifyReceipt to get decoded transaction information. In the in_app field of the response you will be getting a series of transactions including an original transaction ID for each one.
Now you can invoke https://api.storekit-sandbox.itunes.apple.com/inApps/v1/history/{originalTransactionId} for each transaction in the in_app array in the previous response, by replacing {originalTransactionId} with each of the original transaction IDs you received in the previous call.
Regarding the 404 response you received: 404 is a standard HTTP status code meaning "NOT_FOUND". In order to get more information about the error you need to inspect the HTTP response body. There, according to the documentation, you will receive an error code indicating the exact nature of the error.

error | 253 | Message specified does not match with any template

I am getting following error while hitting gupshup send message API:
error | 253 | Message specified does not match with any template
If you are sending any messages from bulk you need to first approve that template by mailing the message content to enterprise-support#smsgupshup.com with your 10 digit gupshup account Id. And also note the approved content should exactly match the message which you are trying to send from API even an extra space can cause error 253

Can't deploy an app to Intune store via graph API - DeviceManagementApps.ReadWrite.All is an invalid scope?

We want to enable uploading apps to the Intune store via an API.
I saw this example on GitHub, and want to do something similar in JS, so I've tried using the same REST calls.
The problem is, I can't seem to make the https://graph.microsoft.com/beta/deviceAppManagement/mobileApps request properly - I always get 401. When making the same request via the Graph API Explorer it works fine.
I tried fixing my permissions, and I'm kinda stuck getting the correct token.
I did the following steps with an admin account, on both the "common" and our own tennant:
Called the admin consent - https://login.microsoftonline.com/nativeflow.onmicrosoft.com/adminconsent?client_id=<ID>&redirect_uri=<URI>
Got authorization from the user - https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=<ID>&response_type=code&redirect_uri=<URI>&response_mode=query&scope=DeviceManagementApps.ReadWrite.All
POST request to get the actual token -
https://login.microsoftonline.com/nativeflow.onmicrosoft.com/oauth2/v2.0/token
with the following body:
client_id: <ID>
scope: https://graph.microsoft.com/.default
client_secret: <secret>
grant_type: client_credentials
requested_token_use: on_behalf_of
code: <The code I got in step 2>
I tried changing the scope in step 3 to https://graph.microsoft.com/DeviceManagementApps.ReadWrite.All or simply to DeviceManagementApps.ReadWrite.All, but it says that it's not a valid scope.
I got a token in step 3, but when I try calling the actual API I receive this error:
{
ErrorCode:"Forbidden",
Message:{
_version: 3,
Message: "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: 7b5c3841-976d-4509-b946-f7fdabd047d7 - Url: https://fef.msub02.manage.microsoft.com/StatelessAppMetadataFEService/deviceAppManagement/mobileApps?api-version=5018-05-02",
CustomApiErrorPhrase: "",
RetryAfter: null,
ErrorSourceService: "",
HttpHeaders: {"WWW-Authenticate":"Bearer realm=urn:intune:service,f0f3c450-59bf-4f0d-b1b2-0ef84ddfe3c7"}
},
Target:null,
Details:null,
InnerError:null,
InstanceAnnotations:[]
}
So yeah, I'm pretty much stuck. Anyone have any experience with it? I've tried making the calls in Postman, curl and via code, but nothing works.
Cheers :)
You have a couple issues going on:
You're using the Authorization Code Grant workflow but requesting Client Credentials.
The scope Device.ReadWrite.All is an application scope, it is only applicable to Client Credentials. It isn't a valid Delegated scope so it will return an error when you attempt to authenticate a user (aka delegate) using Device.ReadWrite.All.
Your body is using key:value but it should be using standard form encoding (key=value).
To get this working, you need to request a token without a user. This is done by skipping your 2nd step and moving directly to retrieving a token (body line-breaks are only for readability):
POST https://login.microsoftonline.com/nativeflow.onmicrosoft.com/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
client_id={id}
&client_secret={secret}
&scope=https%3A%2F%2Fgraph.microsoft.com%2F.default
&grant_type=client_credentials

Error with WSO2 API Manager OAuth Authentication

I installed the latest WS02 API Manager, 1.6.0. I followed the directions and just did the plain install, nothing special. When I create an API, publish it, subscribe to it, create an Access Token, and try to access it, I am seeing the following error (I replaced the access key, but it is displaying):
[2014-02-03 13:25:47,850] ERROR - APIAuthenticationHandler API authentication failure
org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException: Access failure for API: /weather, version: 1 with key: access_key
It seems that the API and access key are not getting connected. Is there something else that I have to do to make that happen? I am not using a separate database for the Key Manager, just whatever comes with the install which is a memory DB I assume. I have tried this from Advanced Rest Client in Chrome. I'm guessing something's just not configured correctly, but I don't see any errors in the start-up. I just see a few warnings along these lines:
[2014-02-03 13:25:01,262] WARN - DefaultSchemaGenerator We don't support method overloading. Ignoring [validateAudience Restriction]
Here is the full stack trace for the error:
[2014-02-03 13:25:47,850] ERROR - APIAuthenticationHandler API authentication failure
org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException: Access failure for API: /weather, version: 1 with key: access_key
at org.wso2.carbon.apimgt.gateway.handlers.security.oauth.OAuthAuthenticator.authenticate(OAuthAuthenticator.jav
a:139)
at org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler.handleRequest(APIAuthenticationHand
ler.java:92)
at org.apache.synapse.rest.API.process(API.java:285)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:76)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:63)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:83)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:336
)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:168)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)

Resources