I'm using this code to get the user geoposition. All goes well until the user deny permission to get the location. It seems this option gets cached and I don't know how reset it.
Is there any way to re-ask permission? Thanks in advance!
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
// Success Callback
}, function(error) {
//error Callback
},{
//options
});
}else{
//geolocation not available
}
Pretty sure this is a browser/device setting stored per site. I think the point is that you can't reset this from a script as it would defeat the point of the prompt in the first place. I believe the only way to reset is to change the setting in the browser/device.
Like bgreater said, it depends on browser. But when user deny permission to get location error function will be called with error object. This error object contains error code. When error code equals 1 it means that user deny permission.
var errorTypes = {
0: "Unknown error",
1: "Permission denied by user",
2: "Position is not available",
3: "Request timed out"
};
I think, you can check this error code and display some kind of information to user.
Related
I'm unable to access the education/users endpoint but I am able to access other endpoints (education/classes, education/schools).
Whenever I try to get a list of all users, I get the following error:
{
"error": {
"code": "AccessDenied",
"message": "Required claim values are not provided.",
"innerError": {
"request-id": "58c42204-440a-482c-b1e9-4c65bb413ed1",
"date": "2018-03-21T20:23:24"
}
}
}
When I try to make the call using the Graph Explorer, I'm given the following notice:
Failure - Status Code - Looks like you may not have the permissions for this call. Please modify your permissions.
Unfortunately, I get the same error after modifying my permissions.
If anyone has any idea why this might be happening, I would be very grateful for the help.
For app+user (delegate) permissions, the only supported scope for the /education/users collection on MSGraph is EduRoster.ReadBasic.
This supports getting an individual user's information, or information on lists of users within classes of which you are a member, but does NOT support browsing the entire set of users in a tenant, as it is deliberately a restricted scope.
If you need more than this, you would need to use app-only permissions, and sync the users into your own data store with EduRoster.Read.All, which would allow you to get all of the users.
I'm creating an app on Outsystems, which uses the Yammer API. The issue is the Yammer authentication is causing some problems. In the "OnReady" property of the page, I've added the following code:
yam.getLoginStatus(
function(response) {
if (response.authResponse) {
console.log("logged in");
$parameters.Token = response.access_token.token;
console.dir(response); //print user information to the console
}
else {
yam.platform.login(function (response) { //prompt user to login and authorize your app, as necessary
if (response.authResponse) {
console.dir(response); //print user information to the console
console.dir(response.access_token.token);
$parameters.Token = response.access_token.token;
console.dir($parameters.Token);
}
});
}
}
);
It successfully returns a token, which I am able to verify using console.log(). Additionally, I've added a Login button which has the same code in its OnClick property.
The issue is, when I try to perform the Get Messages API call (Endpoint: https://www.yammer.com/api/v1/messages.json) from OnReady, it gives me the 401 Unauthorized access error. But, when I additionally use the OnReady, and also click the Login button, the API call is successful. I don't understand why, because the token received by both calls are the exact same, but it works after the user logs in twice? Any way to rectify this?
P.S. I've tried using the other endpoint (https://api.yammer.com/api/v1/messages.json). I'm getting the same problem.
Try adding a $resolve() inside the callback function. This way the code will wait until it finished before continuing to your next jav
I am getting this exception in my background.html page. I don't know what this exception says. Can anyone explain this exception and also tell me how to resolve this exception.
The exception details are
Unchecked runtime.lastError while running storage.set: QUOTA_BYTES_PER_ITEM quota exceeded
Thank you.
This error comes when you use chrome.storage.sync.set...to set the data greater than 8,192 bytes for a single item as chrome.storage.sync.set allows 8,192 QUOTA_BYTES_PER_ITEM.
Use chrome.storage.local.set, to save the large data...instead of chrome.storage.sync.set.
As chrome.storage.local.set can contains 5242880 :QUOTA_BYTES.
See https://developer.chrome.com/extensions/storage
Also, you can get the alert if still want to use chrome.storage.sync.set using below code:
chrome.storage.sync.set(function() {
var error = chrome.runtime.lastError;
if (error) {
alert(error);
}
});
If you are getting same warning with chrome.storage.local too, then
Reason: The data you are trying to store is greater than the allowed storage with local i.e. 5242880 QUOTA_BYTES.
Solution: You can set the permission as unlimitedStorage in manifest.json file.
"permissions": [
.....
"unlimitedStorage",
.....
],
For more regarding permission
1) https://developer.chrome.com/extensions/storage#property-managed
2) https://developer.chrome.com/extensions/permission_warnings#nowarning
As outlined by wOxxOm in his comment above, the answer is covered in the chrome.storage documentation.
Moreover, it's always a good practice to implement error handling and check for runtime.lastError. If everything is all right, it will be undefined. If there is a problem, it will be non-empty, and chrome.runtime.lastError.message will explain what's wrong.
Chrome added checks that chrome.runtime.lastError is actually checked (evaluated). If not, it considers this to be an unhandled exception, and throws this error.
I'm trying to upload images generated in my Flash application to an album on Facebook. This was working earlier in the year, but revisiting the code I now get the following OAuthException:
(#324) Requires upload file
I am using the most recent version of the ActionSccript Facebook API. The setup works like this:
First I do the authentication check with PHP to ensure users have granted permission before having to wait for the Flash to load. I'm requesting the publish_stream and user_photos permissions. The access token comes back correctly.
Once the user is authenticated the Flash is loaded and performs its own initialisation, passing fileUpload=true as part of the init object:
var initObject:Object = {
channelUrl : "myChannelURL.html",
fileUpload : true
}
Facebook.init(
'myAppID',
myCallbackFunction,
initObject,
myAccessToken
);
This seems to work as expected, the callback receives the uid of the current user.
At the end of my application I POST a Bitmap object to a predetermined album:
Facebook.api(
albumID+"/photos",
onImagePost,
{
message:"",
image:new Bitmap(myBitmapData),
fileName:''
},
URLRequestMethod.POST
);
At this point Facebook returns a 400 response:
"error": {
"message": "(#324) Requires upload file",
"type": "OAuthException"
}
What more do I need to do to ensure that this permission is being included?
It turns out that this was not a permissions error at all. Since I last deployed this code Facebook have tightened up their restrictions a bit, and the fileName parameter passed as part of the api call can no longer be an empty string. Simply passing any old text as a file name fixes the problem.
Facebook.api(
albumID+"/photos",
onImagePost,
{
message:"",
image:new Bitmap(myBitmapData),
fileName:'FILE' // required to be non-empty
},
URLRequestMethod.POST
);
Im not sure if this is a solution that can be translated into the Actionscript SDK... But, with the PHP SDK there is a method inside the facebook SDK that is called setFileUploadSupport - try looking in the code for a place to set that parameter to true.
I have this in my background.html:
chrome.management.onEnabled.addListener(function(ExtensionInfo info) {
alert('123');
});
which gives me an error: Uncaught SyntaxError: Unexpected identifier
If I remove info from function(ExtensionInfo info), I don't get any errors, but it's not firing the alert. Where did I go wrong?
Also, I added "management" inside permissions in manifest.json, so that's not the problem.
You won't be able to catch chrome.management.onEnabled event for your own extension.
If you are trying to execute some code on first extension installation then you would need to store some flag in a local storage.
background.html
if(!localStorage["first_run"]) {
//do something at first run here
localStorage["first_run"] = "done";
}
(for more advanced solution see this answer)
If you want to execute some code each time extension starts (browser startup) just put in into background.html.