Why am I getting authorization code is not in a recognised format? - oauth

Hello everyone I need help please. This is about Seatgeek Oauth request.
In Postman, entered the required fields to get access token.However I am getting this error below.
{
"status": 400,
"message": "Oauth code invalid",
"errors": [
{
"message": "Oauth code invalid",
"short_message": "Code invalid",
"verbose_message": "The authorization code provided was not in a recognized format.",
"hint_message": "Switch code verifier",
"category": null,
"parameter": null,
"code": 40322
}
],
"meta": {
"status": 400
}
}
Now let me add the endpoints I used
Base endpoint: https://api.seatgeek.com/2/oauth/access_token
Params: client_id = xxxxxxxxx
Params: scope = offline_access,read-user-first-name,read-user-email,read-user-phone,view-soundersfc-crm-id
Params:grant_type = authorization_code
Body:x-www-form-urlencoded:
client_secret = xxxxxxxxxxx
code = “ ”
The full url will be something like this : https://api.seatgeek.com/2/oauth/access_token?client_id=xxxxxxxxx&scope=offline_access,read-user-first-name,read-user-email,read-user-phone,view-soundersfc-crm-id&grant_type=authorization_code
Please help me identify this code error. Any help will be highly appreciated
here is the Seatgeek Oauth documentation.
https://partners.seatgeek.com/enterprise-client-integration/oauth

SeatGeek API OAuth documentation not accuracy. you need a little change a scope.
(just use offline_access)
#1 Using this URL from Browser
https://seatgeek.com/oauth2?scope=offline_access&client_id=MzA...zcy
#2 You can get the code in URL address of browser
It will return your registered redirect URL and code
Copy that code and call POST to get token by curl
#3 Get token
curl -X "POST" "https://api.seatgeek.com/2/oauth/access_token" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
--data-urlencode "code={received_code_from_#2}" \
--data-urlencode "client_id={your_client_id}" \
--data-urlencode "client_secret={your_client_secret}" \
--data-urlencode "grant_type=authorization_code"
Note #1
you can get the client id /secret from developer portal
Note #2
code is JWT format. The payload is this content.
I decoded from jwt.io

Related

Error when read reviews from Google My Business REST API

FIrst I get the access token, then I run command in Postman/Insomnia. Below is the cURL version:
curl --request GET \
--url https://mybusiness.googleapis.com/v4/accounts/103754858715037057901/locations/ChIJfSoYcTGuEmsR1Vs1rPs6WRw/reviews \
--header 'Authorization: Bearer ya29.a0AfH6SMCfj3Ekjj8qwudOSYqIj8cEcHvtpyLyQ1SRFvQc62ItV7ph2PJeFLqIzuh41IxDKmel348DerYSQx-AaxcNw_7iYmWcSZUfl85uiZK_SOMEACCESSTOKEN_GpBAFXeVbGWeCPjyk1BjF8spjmQzNO' \
--header 'Content-Type: application/json' \
--header 'X-GOOG-API-FORMAT-VERSION: 2'
But I get error like below:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.mybusiness.v4.ValidationError",
"errorDetails": [
{
"code": 3,
"message": "Resource could not be found"
}
]
}
]
}
}
What did I missed here?
The account already enable the API and billing.
In my case, the problem was incorrect Location ID. I was under impression that Place ID is same with Location ID, it's not. Place ID is alpha-numeric, and Location ID is numeric-only
To get location ID, you need to:
Get Profile ID, then
Get list of Location IDs that belong to that Profile ID
After getting the correct Location ID, I get can the reviews
Permana is correct that you need the Profile ID and not the Place ID. I would like to add to Permana's answer to make it easier for others to find the Profile ID. The Profile ID can be found by logging into the Business Profile Manager -> Businesses (left-hand side at the bottom) and then clicking on the "See your profile" button. Doing so will open up Google search. Click on the three dots next to "Your business on Google" -> Business Profile Settings -> Advanced Settings.

calling activities:list fails on using parameter `mine=true` (Youtube Data API V3)

I have been trying to use the API to retrieve my activities but I'm receiving the following JSON error.
{
"error": {
"code": 403,
"message": "The request is not properly authorized.",
"errors": [
{
"message": "The request is not properly authorized.",
"domain": "youtube.activity",
"reason": "forbidden"
}
]
}
}
, although I use https://www.googleapis.com/youtube/v3/activities?mine=true&key={my_api_key}&part=contentDetails and I use OAuth2 client to get an access token which I use on calling the API.
I tried to use the samples but I'm receiving the same error.
Is this a bug or I'm doing something wrong?
More details
I use the given link in postman with the GET method and I put a valid access token in the token field with TYPE=OAuth2 and Prefix=Bearer
According to the official specification of the Activities.list API endpoint, for to be able to use its mine request parameter, you have to issue the call to the endpoint while passing to it proper credentials:
mine (boolean)
This parameter can only be used in a properly authorized request. Set this parameter's value to true to retrieve a feed of the authenticated user's activities.
Therefore, using an API key is not sufficient (neither is required when issuing a properly authorized request).
Do note that the JSON error response obtained from the API agrees entirely with the specification quoted above.
According to the official (programming language agnostic) procedure, for to obtain a valid fresh access token from the API, issue a simple curl instance as follows:
$ curl \
--data 'grant_type=refresh_token' \
--data-urlencode "client_id=$CLIENT_ID" \
--data-urlencode "client_secret=$CLIENT_SECRET" \
--data-urlencode "refresh_token=$REFRESH_TOKEN" \
https://oauth2.googleapis.com/token
Above, $CLIENT_ID and $CLIENT_SECRET are the values of the corresponding properties of your client secrets JSON file you've got from Google's developers console. The $REFRESH_TOKEN is your (long-lived) refresh token you've obtained upon running a successful OAuth2 authentication/authorization flow.
The output obtained from curl when successful would look like:
{
"access_token": "...",
"expires_in": 3599,
"scope": "...",
"token_type": "Bearer"
}
A call to the Activities.list endpoint as yours above using curl is immediate:
$ curl \
--header "Authorization: Bearer $ACCESS_TOKEN" \
'https://www.googleapis.com/youtube/v3/activities?mine=true&part=contentDetails&maxResults=25'
The parameter $ACCESS_TOKEN above is your freshly obtained valid access token; the output of curl would look like:
{
"kind": "youtube#activityListResponse",
"etag": "...",
"items": [
{
"kind": "youtube#activity",
"etag": "...",
"id": "...",
"contentDetails": {
...
}
},
...
],
"pageInfo": {
"totalResults": ...,
"resultsPerPage": 25
}
}
For to run the above curl commands on a Windows machine under CMD.exe -- assuming that you've substitued the $-variables yourself manually --, do replace the backslash character at the end of each line above with the caret character, ^. The percent character % should be doubled, i.e. should be replaced with %%, and the single quote characters ' should be replaced with double-quote characters ".

Failed to exchange a code for an access token for creating zendesk instance in cloud element through API

Please help to create zendesk instance in cloud element by 3rd party api call
Created Zendesk account Created & configure as per in Link
Succesfully got Elements OAuth Information
{
"oauthUrl": "https://yoursubdoamin.zendesk.com/oauth/authorizations/new?response_type=code&client_id=zendesk_unique_identifier&redirect_uri=http://www.my_cool_app.com/auth&scope=read write&state=zendesk",
"element": "zendesk"
}
Getting error in API
curl -X POST
-H 'Authorization: User <INSERT_USER_SECRET>, Organization <INSERT_ORGANIZATION_SECRET>'
-H 'Content-Type: application/json'
-d #instance.json
'https://api.cloud-elements.com/elements/api-v2/instances'
instance.json
{
"element": {
"key": "zendesk"
},
"providerData": {
"code": "Code on Return the URL"
},
"configuration": {
"oauth.api.key": "<INSERT_ZENDESK_UNIQUE_IDENTIFIER>",
"oauth.api.secret": "<INSERT_ZENDESK_CLIENT_SECRET>",
"oauth.callback.url": "https://www.my_cool_app.com",
"zendesk.subdomain": "<INSERT_ZENDESK_SUB_DOMAIN>"
},
"tags": [
"<INSERT_TAGS>"
],
"name": "<INSERT_INSTANCE_NAME>"
}
Getting error "Failed to exchange a code for an access token"
This might be because, you might not have registered an app with zendesk to get back the access token. This can also happen if your element in Cloud Elements is corrupted, make sure you are using the inbuild element instance. Still if you are facing the issue, please mention the steps you followed

Getting list of users in Google Admin SDK

I have OAuth login in my app. After that I have access_token.
I check token in google token info service:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<access_token>
And It returns:
{
"issued_to": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"audience": "554651647288-tquejcu6mctplq4kin5dd9r81mtkg3vv.apps.googleusercontent.com",
"scope": "https://www.googleapis.com/auth/admin.directory.group https://www.googleapis.com/auth/admin.directory.orgunit https://www.googleapis.com/auth/admin.directory.user",
"expires_in": 3299,
"access_type": "online"
}
As you can see I have admin user directory permission.
Then I send GET request for getting information about user
curl -X GET https://www.googleapis.com/admin/directory/v1/users/test_user#test.com?access_token=<access_token>
And google returned me right user information. After that I decided to get list of users.
curl -X GET https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&access_token=<access_token>
And google returned me:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
But I don't understand why google returned me so error.
Could you please help me with this problem?
Thanks.
There are two solutions here.
1.This is the simple one. Put the URL params in quotes. This should do the trick - (fake access token used)
curl "https://www.googleapis.com/admin/directory/v1/users?customer=my_customer&access_token=asdf.AHEasdfyIc9vuPQ_BGONpzEJkasdfWYXGujPw5iPI"
You don't need to pass in -X GET as that is the default.
2.In general it is bad practice to send the access_token in the URL as this URL may get logged somewhere along the way for innocuous reasons. You can also do this through HTTP Header of Authorization -
curl -H "Authorization: Bearer asdf.AHEasdfyIc9vuPQ_BGONpzEJkasdfWYXGujPw5iPI" https://www.googleapis.com/admin/directory/v1/users?customer=my_customer

YouTube V3 Create Broadcast

I am trying to create a broadcast using YouTube's v3 API. My request looks like this:
curl -H "Authorization: Bearer ******************" -H "Content-type: application/json" -d " {\"snippet\":{\"title\":\"Hello\", \"scheduledStartTime\":\"2014-01-30T00:00:00.000Z\", \"scheduledEndTime\":\"2014-01-31T00:00:00.000Z\"},\"status\":{\"privacyStatus\":\"public\"}}" https://www.googleapis.com/youtube/v3/liveBroadcasts?part=snippet,status
But the response I get from google is this:
{
"error": {
"errors": [
{
"domain": "youtube.liveBroadcast",
"reason": "liveBroadcastForbidden",
"message": "Request is not authorized"
}
],
"code": 403,
"message": "Request is not authorized"
}
}
I can confirm that the access token I am passing is correct.
Is there something I am doing wrong here?
Livestreaming API is only available to partners right now. It will be more widely available later.
If you have gotten the granted access, you should enable YouTube APIs from API Console. It looks like you haven't enabled them.

Resources