Google Fit authorization code for a in device application - oauth-2.0

I'm trying to get the authorization code for a in device application but I get an invalid scope error.
I'm making the call using this command from terminal:
curl -d "client_id=XXX&scope=https://www.googleapis.com/auth/fitness.activity.read" https://accounts.google.com/o/oauth2/device/code
And I'm getting this response:
{
"error" : "invalid_scope",
"error_description" : "Not authorized to request the scopes: [https://www.googleapis.com/auth/fitness.activity.read]",
"error_uri" : "http://code.google.com/apis/accounts/docs/OAuth2.html"
}
Am I doing something wrong? The application is authorized for fitness api.

The in device oauth-2.0 flow was not enabled for the Google-Fit API. It is now enabled.
Source: https://plus.google.com/106927497941034280613/posts/PwQ2uzq8Y4f

Related

Tapkey token exchange is successful, but getting a 400 Bad Request when trying to login

I am successfully using the Tapkey token exchange endpoint to exchange a Firebase token for a Tapkey one, but am then having an error calling login.
I am requested the following Scope's when exchanging the token:
register:mobiles read:user read:ip:users handle:keys
My swift code is below (basically lifted straight from the documentation):
let authToken = ExchangeFirebaseTokenForTapkeyToken(firebaseToken);
if authToken == nil {
return
}
// For testing purposes, normally this would be static and only built once
let serviceFactory = TKMServiceFactoryBuilder()
.setTokenRefreshHandler(TapkeyTokenRefreshHandler())
.build()
let userManager = serviceFactory.userManager
let result = userManager.logInAsync(accessToken: authToken!, cancellationToken: TKMCancellationTokens.None)
result.continueOnUi { (userId) -> Void in
print(userId as Any)
}
.catchOnUi { (error) -> Void in
print(error)
}
.conclude()
The logs are below, as you can see I get a Failed to authenticateAsync error, and a HTTP 400 response.
2021-06-14 14:25:48.805135+0100 App[11940:234234] LogonManager: start authentication
Jun 14 14:25:48 [11940] : LogonManager: start authentication
2021-06-14 14:25:48.805917+0100 App[11940:234234] NetTpkyMcRestLoggingAsyncHttpRequestExecutor: Request POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' started.
Jun 14 14:25:48 [11940] : NetTpkyMcRestLoggingAsyncHttpRequestExecutor: Request POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' started.
2021-06-14 14:25:49.464429+0100 App[11940:234234] NetTpkyMcRestLoggingAsyncHttpRequestExecutor: Request POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' completed with code 400 after 659ms.
Jun 14 14:25:49 [11940] : NetTpkyMcRestLoggingAsyncHttpRequestExecutor: Request POST 'https://my.tapkey.com/api/v1/Auth/Auth/UserInfo?t=tk' completed with code 400 after 659ms.
2021-06-14 14:25:49.476961+0100 App[11940:234234] AuthenticationManagerImpl: Failed to authenticateAsync
If I provide any value other than the access key returned from the Token Exchange endpoint, I get a 401 Unauthorised (which is to be expected).
I have tried adding this user to the portal, but I still have the same issue.
Is there anything else I need to do, or any extra configuration I need to add to my iOS app? I have matched my configuration with the sample app (as far as I can tell) to no avail.
Thanks
Users of external identity providers have to be registered before the can login.
You can find the details here:
https://developers.tapkey.io/api/authentication/identity_providers/#working-with-users
When it is necessary for your use case, that these users are automatically created when they login, please send a request to tapkey support and they will enable this feature for you.

Slack call API - getting 500 error when posting on response url

I am trying to build a calling app on slack that invokes a voip app installed on the computer. So when the slack app is given a particular command with a number it should invoke this desktop app and allow the user to make a call.
I have given the slack app calls:read
calls:write permissions but when i post a message from the service back to slack on response_url i am getting 500 error on slack.
slack_message = {
"response_type": "Call",
"call_initiation_url": "https://example.com",
"desktop_protocol_call_initiation_url": "sip:+15551231234?action=call"
}
header = {'Content-Type': 'application/json'}
response = requests.post(response_url, headers=header, data=json.dumps(slack_message))
Slack show 500 error.
However, posting back to response_url works when i post back a simple message, like shown below and i see it on the slack.
slack_message2 = {
"response_type": "in_channel",
"text": "It's 80 degrees right now."
}
Could some help in understanding what is going wrong ? I am stuck here.

Twilio Invalid Access Token Signature (iOS - Swift)

I am using Twilio's latest SDK they released on CocoaPods as of today. I am trying to implement VOIP feature to my app with Twilio Programmable Voice. My backend is .net which also uses the latest release of Twilio Helper Library for C#.
My client code looks like:
fetchAccessToken { (accessToken: String) in
TwilioVoice.register(withAccessToken: accessToken, deviceToken: deviceToken) { (error) in
if let error = error {
NSLog("An error occurred while registering: \(error.localizedDescription)")
}
else {
NSLog("Successfully registered for VoIP push notifications.")
}
}
}
What I get in the console is as following:
voipTestWithTwilio[2431:517236] [ERROR TwilioVoice] Inside register:deviceToken:completion:, failed to register for Twilio push notifications. Error:Invalid access token signature
voipTestWithTwilio[2431:517236] An error occurred while registering: Invalid access token signature
This is the C# code that actually creates the token:
var grant = new VoiceGrant
{
OutgoingApplicationSid = outgoingApplicationSid
};
var grants = new HashSet<IGrant> { { grant } };
var token = new Token(
accountSid: accountSid,
signingKeySid: apiKey,
secret: apiSecret,
identity: identity,
grants: grants
);
return token.ToJwt();
I have been looking for the issue on the internet, nothing helped so far. I have tried contacting them but have not got any response back. I also tried creating new api keys and even a new project for a couple times on Twilio. Can anybody say something about the issue?
UPDATE
I added push notification sid to VoiceGrant and now I’m getting 403 Forbidden.
On Twilio error codes page it is explained as: “The expiration time provided in the Access Token exceeds the maximum duration allowed.” which is definitely not my case. However, I tried passing expiration parameter in Token constructor with various values which didn’t change the result.
The problem is still persisting.
I solved the issue. It was because my server returned the token with quotation mark.
I remember print(token)'ing on client (iOS) to see whether there is encoding issue or something and all I see was a proper token between quotation marks. Since token is a string value, I didn't pay attention to quotation part of it. That's where I was wrong.

Error when trying to join a channel via API

im using slack to make chat bot so i can create a message center from my ios app to send message from ios app to slack.
getting following response from hitting joinChannel api https://slack.com/api/channels.join
cant get channel ids
{
"provided" : "admin,identify,chat:write:bot",
"ok" : false,
"needed" : "channels:write",
"error" : "missing_scope"
}
As the error message says you need the channels.write scope to use channels.join method.
Just add the missing scope to your access token and it will work.

Posting on Groups using Facebook Graph API with Koala gem returns "Insufficient permissions"

I have the following permissions from the user in the app
[{"permission"=>"user_managed_groups", "status"=>"granted"},
{"permission"=>"email", "status"=>"granted"},
{"permission"=>"manage_pages", "status"=>"granted"},
{"permission"=>"publish_pages", "status"=>"granted"},
{"permission"=>"publish_actions", "status"=>"granted"},
{"permission"=>"public_profile", "status"=>"granted"}]
Now, when I try to publish anything on a group user manages, I get "Insufficient permissions"
I am using Koala gem to get this done as follows,
pry> client.put_connections(<<group_id>>, 'feed', message: 'Hi')
Koala::Facebook::ClientError: type: OAuthException, code: 200, message: (#200) Insufficient permission to post to target on behalf of the viewer [HTTP 403]
from /Users/Sagar/.rvm/gems/ruby-2.2.1/gems/koala-2.0.0/lib/koala/api/graph_api.rb:500:in `block in graph_call'
How can I make this work?
Ok! Got the answer of this one!
These permissions have one more aspect attached to them that is "App Visibility". If the app visibility is set of "Only Me", one will get the error "Insufficient Permission" even if all the permissions are granted.
To change the visibility, the user can go to the Settings -> Apps -> App Visibility and set it Public (preferably).

Resources