Getting Daily Limit for unauthenticated use Exceeded - xamarin

Getting Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup
when executing the following code given in the Xamarin demo
async void OnAuthenticationCompleted (object sender, AuthenticatorCompletedEventArgs e)
{
if (e.IsAuthenticated) {
// If the user is authenticated, request their basic user data from Google
// UserInfoUrl = https://www.googleapis.com/oauth2/v2/userinfo
var request = new OAuth2Request ("GET", new Uri (Constants.UserInfoUrl), null, e.Account);
var response = await request.GetResponseAsync ();
if (response != null) {
// Deserialize the data and store it in the account store
// The users email address will be used to identify data in SimpleDB
string userJson = response.GetResponseText ();
App.User = JsonConvert.DeserializeObject<User> (userJson);
e.Account.Username = App.User.Email;
AccountStore.Create ().Save (e.Account, App.AppName);
}
}
// If the user is logged in navigate to the TodoList page.
// Otherwise allow another login attempt.
App.SuccessfulLoginAction.Invoke ();
}
This is the error I am getting
"error":{
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message" :"Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
"extendedHelp" : "https://code.google/apis/console"
}
],
"code":403,
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup."
}

I corrected the redireturl to "http://example.com/oauth2callback" and in the ios project modified the ATS setting by adding the following key in info.plist
NSAppTransportSecurity -- Dictionary
NSAllowsArbitraryLoadsInWebContent -- Boolean -- Yes

Related

get googlesheets cells with name sheet with accents

I try to use the gradle exemple to get googlessheets cells and get error with the tab name with diacritics ("Opérations 2023") because the name is in french.
https://developers.google.com/sheets/api/quickstart/java
the error is below.
{
"code": 400,
"errors": [
{
"domain": "global",
"message": "Unable to parse range: Op%C3%A9rations%202023!A2%3AE2",
"reason": "badRequest"
}
],
"message": "Unable to parse range: Op%C3%A9rations%202023!A2%3AE2",
"status": "INVALID_ARGUMENT"
}
The request is
public static void main(String... args) throws IOException, GeneralSecurityException {
// Build a new authorized API client service.
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
final String spreadsheetId = "ID";
final String range = "Opérations 2023!A2:E2";
Sheets service =
new Sheets.Builder(HTTP_TRANSPORT, JSON_FACTORY, getCredentials(HTTP_TRANSPORT))
.setApplicationName(APPLICATION_NAME)
.build();
ValueRange response = service.spreadsheets().values()
.get(spreadsheetId, range)
.execute();
List<List<Object>> values = response.getValues();
if (values == null || values.isEmpty()) {
System.out.println("No data found.");
} else {
System.out.println("Name, Major");
for (List row : values) {
// Print columns A and E, which correspond to indices 0 and 4.
System.out.printf("%s, %s\n", row.get(0), row.get(4));
}
}
}
}
What can I do please ?
I'm writing this answer as a community wiki, since the issue was resolved from the comments section, in order to provide a proper response to the question.
I tested with Sheets API Method: spreadsheets.values.get and I had no issues using it with sheet named "Opérations 2023" so it seems is not issue with the API but character encoding in Java.
I'm not an expert in Java, but while doing research, I found a similar thread and it shows the same error when using Java while doing it with Python it seems to work with no issue.
As a workaround, if the sheet you're aiming to is the first one in your Worksheet, then you can just omit the name of the Sheet and set the range to: "A2:E2", this will aim the default sheet which is the first one in your Worksheet.

Plaid - Update mode not working showing ITEM_LOGIN_REQUIRED

I am new to plaid.
I created a plaid access_token and now its showing
"error_code":"ITEM_LOGIN_REQUIRED"
Using the doc I understand that we need to use update mode for solving this
then access token will not change and no need to call token -exchange
after getting this error
I tried calling
https://sandbox.plaid.com/link/token/create
method -POST
{
"client_id": "xxxxxx",
"secret": "xxxxxx",
"client_name": "test",
"user": { "client_user_id": "xxxx" },
"country_codes": ["US"],
"language": "en",
"access_token": "access-sandbox-xxxx-xxx-xxx-xxx-111111"
}
then I got new link_token
{
"expiration": "2021-11-09T13:46:12Z",
"link_token": "link-sandbox-xxxx-xxx-xxxx-xxx-xxx",
"request_id": "xxxxx"
}
Then after what I need to do ?? .. I understand that no need to do token exchange api.
but if I tried to use this api using the existing access-token it is showing the same error
https://sandbox.plaid.com/accounts/get
method -POST
{
"client_id": "xxxxxx",
"secret": "xxxxxx",
"access_token": "access-sandbox-xxxx-xxx-xxx-xxx-111111"
}
output
{
"display_message": null,
"error_code": "ITEM_LOGIN_REQUIRED",
"error_message": "the login details of this item have changed (credentials, MFA, or required user action) and a user login is required to update this information. use Link's update mode to restore the item to a good state",
"error_type": "ITEM_ERROR",
"request_id": "3LMjpQHxYAMDwos",
"suggested_action": null
}
in that document they are saying like this.
An Item's access_token does not change when using Link in update mode, so there is no need to repeat the exchange token process.
then why I am getting again this ??
What I need to do solve this issue?
// Initialize Link with the token parameter
// set to the generated link_token for the Item
const linkHandler = Plaid.create({
token: 'GENERATED_LINK_TOKEN',
onSuccess: (public_token, metadata) => {
// You do not need to repeat the /item/public_token/exchange
// process when a user uses Link in update mode.
// The Item's access_token has not changed.
},
onExit: (err, metadata) => {
// The user exited the Link flow.
if (err != null) {
// The user encountered a Plaid API error prior
// to exiting.
}
// metadata contains the most recent API request ID and the
// Link session ID. Storing this information is helpful
// for support.
},
});
After getting the Link token, you need to initialize Link with the Link token. Per the docs:
"To use update mode for an Item, initialize Link with a link_token configured with the access_token for the Item that you wish to update."
https://plaid.com/docs/link/update-mode/
Once the user has successfully completed the Link flow, the access token should be reactivated.

Golang GMAIL API 400: Invalid label:

Using Gmail API to read my mailbox. The message reading process is working as expected but I want to change the label of reading messages just for acknowledgment purposes so that I can have track of the reading messages list in my Gmail inbox only. Tried given two methods to change the label but non of them worked for me. Need suggestion on the same
Methods:
Codebase is written in Golang (as a backend)
Tried with Google API Explorer
(METHOD 1) -
Go sample code:
gmsg: = gmail.ModifyMessageRequest {
RemoveLabelIds: [] string {
"INBOX". //system defined label
},
AddLabelIds: [] string {
"INBOXING" //my custom label. created through Gmail
},
}
_, errDelete: = gService.Users.Messages.Modify("me", messageid, &gmsg).Do()
if (errDelete != nil) {
logs.Error("GMAIL SERVICE ERROR:: for [", accountEmail, "] while moving message to [INBOXING] folder ", errDelete.Error())
}
Got below error :
{"level":"error","msg":"GMAIL SERVICE ERROR:: for [sample#gmail.com] while moving message to [INBOXING] folder googleapi: Error 400: Invalid label: INBOXING, invalidArgument","time":"2021-08-09 20:05:13"}
(METHOD 1) -
Gmail Modify API
Payload
{
"addLabelIds": [
"INBOXING"
],
"removeLabelIds": [
"INBOX"
]
}
Response from Google API -
{
"error": {
"code": 400,
"message": "Invalid label: INBOXING",
"errors": [
{
"message": "Invalid label: INBOXING",
"domain": "global",
"reason": "invalidArgument"
}
],
"status": "INVALID_ARGUMENT"
}
}
Observation - *
On modifying message with custom label's Gmail API return's 400 bad
request, but if we request with system labels it allows us to modify
the label.
You are using the label name instead of label id. To obtain the label id, you have to use the Method: users.labels.list
Response:
Once you have the ID, you can now use it in Method: users.messages.modify
Request body:
Response:

Servicestack GlobalRequestFilters populating additional user auth data into Jwt tokens

I want to add additional properties to the response when a user logs in.
When calling https://Servicestackservice/auth/credentials?userName=****&password=**** I get the below response. I want to add 2 additional values. DateFormat & TimeZone
{
"userId": "21",
"sessionId": "****",
"userName": "SystemAdmin",
"displayName": "System Admin",
"referrerUrl": null,
"bearerToken": "****",
"refreshToken": *",
"profileUrl": *",
"roles": [ View
],
"permissions": [ View
],
"responseStatus": {
"errorCode": null,
"message": null,
"stackTrace": null,
"errors": null,
"meta": null
},
"meta": null
}
I found an example from the SS forums. I had to modify it some to make it run.
From the SS docs
Modifying the Payload
Whilst only limited info is embedded in the payload by default, all matching AuthUserSession properties embedded in the token will also be populated on the Session, which you can add to the payload using the CreatePayloadFilter delegate. So if you also want to have access to when the user was registered you can add it to the payload with:
I am hoping this is how i get them into the "matching AuthUserSession"
this.GlobalRequestFilters.Add(async (req, res, requestDto) =>
{
AuthFilter.AuthResponse(req, res, requestDto);
});
public static void AuthResponse(IRequest req, IResponse res, object response)
{
var authRes = response as Authenticate;
if (authRes == null || authRes.UserName == null)
{
return;
}
var session = (CustomUserSession)req.GetSession();
if (session != null && session.UserAuthId != null)
{
//General Format for US
string dformat = "g";
using (var db = HostContext.TryResolve<IDbConnectionFactory>().Open())
{
var userAuthExt = db.Single<UserAuthExtension>(ext => ext.UserAuthId == int.Parse(session.UserAuthId));
if (userAuthExt != null)
{
dformat = userAuthExt.DateTimeFormat;
}
}
authRes.Meta = new Dictionary<string, string> {{"TimeZone", session.TimeZone}, {"DateFormat", dformat}};
}
}
Adding this to try to get the JWT tokens to hold the new data. Examining the payload i can see the 2 new values are added to the list.
new JwtAuthProvider(AppSettings)
{
CreatePayloadFilter = (payload, session) =>
{
if (session != null && session.UserAuthId != null)
{
//General Format for US
string dformat = "g";
using (var db = HostContext.TryResolve<IDbConnectionFactory>().Open())
{
var userAuthExt = db.Single<UserAuthExtension>(ext => ext.UserAuthId == int.Parse(session.UserAuthId));
if (userAuthExt != null)
{
dformat = userAuthExt.DateTimeFormat;
}
}
payload["TimeZone"] = ((AuthUserSession) session).TimeZone;
payload["DateFormat"] = dformat;
}
},
You should link to the docs you're referring to, which I believe is ServiceStack's JWT Modifying the Payload docs. Although it's not clear which example in the Customer Forums you're referring to.
It's also not clear what the question is, I'm assuming it's this statement:
When calling /auth/credentials?userName=****&password=**** I do not see the new values.
Where exactly are you expecting these values? If you're authenticating by credentials you're not Authenticating by JWT so you will not have these additional properties populated on your User Session. If they're embedded in your JWT's body payload then as TimeZone is a AuthUserSession property, it should be populated if it was contained within the JWT payload:
case "TimeZone":
authSession.TimeZone = entry.Value;
break;
But DateFormat is not an AuthUserSession property so you will need to populate it manually by providing an implementation for PopulateSessionFilter, e.g:
new JwtAuthProvider(AppSettings)
{
PopulateSessionFilter = (session,payload,req) =>
session.Meta["DateFormat"] = payload["DateFormat"];
}
But these properties are only going populated in the Users Session when authenticating via JWT.
To help diagnose any issues you should but a breakpoint in your CreatePayloadFilter to see what you've populated the JWT payload with and conversely put a breakpoint in your PopulateSessionFilter to inspect what's contained in the payload and resulting populated session.

Web Api Query for Actions msdyn_BookingResource and msdyn_BookingResourceRequirement

From the web api reference here
I tried querying the api with no luck of success specially with the parameter Schedules being stated as type string.
1.) For msdyn_BookingResource
POST: https://bhaud365dev.crm6.dynamics.com/api/data/v9.0/msdyn_BookingResource
BODY:
{"ResourceId":[GUID],"BookingStatusId":[GUID],"BookingMethod":690970003,"BookingType":1,"Schedules":"[{\"StartDateTime\":\"2019-07-15T00:00:00Z\",\"EndDateTime\":\"2019-07-19T00:00:00Z\"}]","Timeframe":5}
RESPONSE: {
"error": {
"code": "0x80040224",
"message": "The added or subtracted value results in an un-representable DateTime.\r\nParameter name: value",
2.) For msdyn_BookingResourceRequirement
POST: https://bhaud365dev.crm6.dynamics.com/api/data/v9.1/msdyn_resourcerequirements([GUID])/Microsoft.Dynamics.CRM.msdyn_BookingResourceRequirement
BODY: {
"BookingMethod": 690970003,
"BookingStatusId": [GUID],
"BookingType": 1,
"EndDateTime": "2019-07-19T07:29:00Z",
"ResourceId": [GUID],
"StartDateTime": "2019-07-15T22:00:00Z"
}
RESPONSE: {
"error": {
"code": "0x80040224",
"message": "Object reference not set to an instance of an object.",
I was able to api query for functions but for the actions I am stuck and I am not sure on what am I doing wrong. Any tips or example is greatly appreciated.
BTW. tried the above queries also in CRM REST BUILDER v2.6.0.0 Same error responses.
I spent some time, getting same weird error and then I realized they are Internal Use only Actions. It's not intended for our usage & it's highly unsupported as they tend to break in future versions when Microsoft planned to change.
I was able to successfully create the Bookable Resource Bookings with the help of below web api request.
var entity = {};
entity["Resource#odata.bind"] = "/bookableresources(7B203E2F-F2FB-E911-A813-000D3A5A1BF8)";
entity["BookingStatus#odata.bind"] = "/bookingstatuses(026BDCEF-9257-4C10-9E49-C92539B883D6)";
entity["endtime"] = "2019-11-07T21:00:00Z";
entity["starttime"] = "2019-11-07T20:00:00Z"
entity.bookingtype = 1;
entity.msdyn_bookingmethod = 690970003;
Xrm.WebApi.online.createRecord("bookableresourcebooking", entity).then(
function success(result) {
var newEntityId = result.id;
},
function(error) {
Xrm.Utility.alertDialog(error.message);
}
);

Resources