I configured email with passwordless login in my Firebase project
And followed the documentation at https://firebase.google.com/docs/auth/web/email-link-auth
My code:
const actionCodeSettings = {
url: "https://acme.com",
handleCodeInApp: true,
dynamicLinkDomain: "acme.com",
};
const response = await firebase.auth().sendSignInLinkToEmail(email, actionCodeSettings);
Which translates to the following request:
curl 'https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=XXX' \
...
--data-raw '{"requestType":"EMAIL_SIGNIN","email":"mugen#acme.co","continueUrl":"https://acme.co","canHandleCodeInApp":true,dynamicLinkDomain:"acme.com"}'
And I get the following response:
{
"error": {
"code": 400,
"message": "OPERATION_NOT_ALLOWED",
"errors": [
{
"message": "OPERATION_NOT_ALLOWED",
"domain": "global",
"reason": "invalid"
}
]
}
}
The domain is in the authorized list. I tried with and without sending the dynamicLinkDomain parameter.
Actually, I faced same problem.
https didn't work, but http worked.
const actionCodeSettings = {
url: "http://acme.com",
handleCodeInApp: true,
dynamicLinkDomain: "acme.com",
};
Related
Since the latest maintenances from ConnectyCube servers, I am experiencing a new issue when I authenticate with the custom identity provider.
I use Firebase as endpoint and it return the following json file (tested with Postman) :
{
"kind": "identitytoolkit#GetAccountInfoResponse",
"users": [
{
"localId": "The uid that I want to get",
"email": "test#test.com",
"passwordHash": "xxxxxx",
"emailVerified": false,
"passwordUpdatedAt": 1607681539305,
"providerUserInfo": [
{
"providerId": "password",
"federatedId": "test#test.com",
"email": "test#test.com",
"rawId": "test#test.com"
}
],
"validSince": "1607681539",
"disabled": false,
"lastLoginAt": "1620422687374",
"createdAt": "1607681539305",
"lastRefreshAt": "2021-05-07T21:24:47.374Z"
}
]
}
Previously, to get the localId, I used the following as responses params {"uid": "#{users[0].localId}"} and it worked.
Now I get the error "base":["Custom Identity Provider uid is required"] when I try to sign in the users while nothing changed in my code.
Do you have a solution to access to the localID parameter without using [0] as it seems to be the cause of the issue?
My current settings for the custom identity provider:
ENDPOINT: https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=API_WEBKEY
REQUEST HEADERS: {"Content-Type": "application/json"}
REQUEST PARAMS: {"idToken": "#{login}"}
RESPONSE PARAMS: {"uid": "#{users[0].localId}"}
Extract of my script where the error appear:
final token = await FirebaseLib().auth.currentUser.getIdToken();
createSession().then((cubeSession) {
CubeUser user = CubeUser(login: "$token", password: "");
signIn(user).then((cubeUser) {
Print("Worked!");
}).catchError((error) {});
}).catchError((error) {});
This should work now again
Please check
I am getting the error while inserting image file into the firebase Stroage. I am using HTTP rest api's for the same.
The code is as follows:
Future<void> upload(Image image2) async {
var accountCredentials = ServiceAccountCredentials.fromJson({
"private_key_id": " ",
"private_key": " ",
"client_email":"< >.iam.gserviceaccount.com",
"client_id": "",
"type": "service_account"
});
var scopes = [
'https://www.googleapis.com/auth/cloud-platform',
];
var client = Client();
AccessCredentials credentials =
await obtainAccessCredentialsViaServiceAccount(accountCredentials, scopes, client);
String accessToken = credentials.accessToken.data;
var request = Request(
'POST',
Uri.parse(
'https://www.googleapis.com/upload/storage/v1/b/mybucket/o?uploadType=media&name=$image2'),
);
request.headers['Authorization'] = "Bearer $accessToken";
request.headers['Content-Type'] = "image/png";
Response response = await Response.fromStream(await request.send());
print("response is ");
print(response.statusCode);
print("response body");
print(response.body);
client.close();
}
The Error is as follows:
{
"error": {
"code": 403,
"message": "< >.iam.gserviceaccount.com does not have storage.objects.create access
to the Google Cloud Storage object.",
"errors": [
{
"message": "< >.gserviceaccount.com does not have storage.objects.create access to the
Google Cloud Storage object.",
"domain": "global",
"reason": "forbidden"
}
]
}
}
I have given the permission of storage.objects.create through IAM service management but this is not working
Click here to view ScreenShot of assigned permission
Hi I am trying to send notification to my app using firebase post method its working fine in postman but when I try to do post method in my app its returning 403. I tried implementing another get request its working fine so no problem with axios setup.
export const postData = function (url, payload) {
return AXIOS.post(url, payload, config);
};
let config = {
headers: {
'Content-Type': 'application/json',
"Authorization" : "key= *****myKey****"
}
};
Here is my post mehtod
let body = {
"to": "******myTokeb*******",
"notification": {
"title": "Title here",
"body": "R(body)",
"mutable_content": true,
"sound": "Tri-tone"
}
};
postData("http://fcm.googleapis.com/fcm/send",body).then((d)=>{
console.log("d",d)
}).catch((e)=>{
console.log("e",e);
});
Error
Error: Request failed with status code 403
at createError (D:\projects\fiver\Roeyat\node_modules\axios\lib\core\createError.js:16)
at settle (D:\projects\fiver\Roeyat\node_modules\axios\lib\core\settle.js:17)
at EventTarget.handleLoad (D:\projects\fiver\Roeyat\node_modules\axios\lib\adapters\xhr.js:61)
at EventTarget.dispatchEvent (D:\projects\fiver\Roeyat\node_modules\event-target-shim\dist\event-target-shim.js:818)
at EventTarget.setReadyState (D:\projects\fiver\Roeyat\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:567)
at EventTarget.__didCompleteResponse (D:\projects\fiver\Roeyat\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:389)
at D:\projects\fiver\Roeyat\node_modules\react-native\Libraries\Network\XMLHttpRequest.js:502
at RCTDeviceEventEmitter.emit (D:\projects\fiver\Roeyat\node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189)
at MessageQueue.__callFunction (D:\projects\fiver\Roeyat\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:425)
at D:\projects\fiver\Roeyat\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:112
Use HTTPS in postData
That will work!
I am trying to send a Firebase Cloud Message from Google Apps Script. I have followed the following questions & links & assembled the following code:
Get 403 response with the "new" Firebase Cloud Messaging API
The res|error I am receiving is:
{
"error": {
"code": 403,
"message": "Request had insufficient authentication scopes.",
"status": "PERMISSION_DENIED"
}
}
My Code in Google Apps Script is:
function sendFCM(text){
text = {
"message": {
"topic": "news",
"notification": {
"title": "Breaking News",
"body": "New news story available."
},
"data": {
"story_id": "story_12345"
}
}
}
var projectId = "xxxxxxx";
var apiUrl = "https://fcm.googleapis.com/v1/projects/"+projectId+"/messages:send";
var authKey = "AAAU.......Cs";
var token = ScriptApp.getOAuthToken();
var options = {
'method' : 'post',
'contentType': 'application/json',
'muteHttpExceptions' : true,
'payload' : JSON.stringify(text),
headers:{Authorization: "Bearer "+ token},
};
var res = UrlFetchApp.fetch(apiUrl, options);
Logger.log(res);
}
Script's properties > User Scopes list follwoing:
https://www.googleapis.com/auth/firebase.database
https://www.googleapis.com/auth/script.external_request
https://www.googleapis.com/auth/spreadsheets
https://www.googleapis.com/auth/userinfo.email
FCM & GCM Api is enabled in project's developer console.
Edit:
From Ref's comment, I added the following scope to app manifest:
https://www.googleapis.com/auth/firebase.messaging
Upon Run, it asked me to authorize & now the response is an instance of a Message. But still I do not know how to define a to device i.e. to which device the message should go.
{
"name": "projects/send-xxxx3/messages/866xxxxx92"
}
I am trying to make an API call to
https://www.googleapis.com/youtube/v3/subscriptions
I'm trying to make it so when a user logs in using google-accounts they will be able to see their YouTube subscription list. It is currently not working at I am not sure why.
Im getting two errors in the console:
1.
www.googleapis.com/youtube/v3/subscriptions?part=subscriberSnippet&mine=true&key=MYKEY&part=snippet&mine=true:1
GET https://www.googleapis.com/youtube/v3/subscriptions?part=subscriberSnippet&…ne=true&key=MYKEY&part=snippet&mine=true 401 (OK)
2.
Object {statusCode: 401, content: "{↵ "error": {↵ "errors": [↵ {↵ "domain": "gl…e": 401,↵ "message": "Invalid Credentials"↵ }↵}↵", headers: Object, data: Object}content: "{↵ "error": {↵ "errors": [↵ {↵ "domain": "global",↵ "reason": "authError",↵ "message": "Invalid Credentials",↵ "locationType": "header",↵ "location": "Authorization"↵ }↵ ],↵ "code": 401,↵ "message": "Invalid Credentials"↵ }↵}↵"data: Objectheaders: ObjectstatusCode: 401__proto__: Object
My code looks as followed:
//client side
Meteor.autosubscribe(function(){
var newUser = Meteor.user();
Meteor.subscribe('currentAccessToken');
});
var url = "https://www.googleapis.com/youtube/v3/subscriptions?part=subscriberSnippet&mine=true&key=key";
var options = {
'headers' : {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + "currentAccessToken",
'X-JavaScript-User-Agent': "Google APIs Explorer"
},
'params' : {
part : 'snippet',
mine : 'true',
}
};
var searchResult = HTTP.call("get", url,options,
function (error, result) {
if (!error) {
Session.set("twizzled", true);
}
console.log(result);
});
On the server side I am publishing the access token so that it can be sent with the GET request
//Server Side
Meteor.publish("currentAccessToken", function(){
return Meteor.users.find(this.userId, {fields: {'services.google.accessToken': 1}});
});
I greatly appreciate any help or documentation.
The first thing to check would be authorization scopes. You have to explicitly add YouTube scope (more than one, actually, each defining single action or a small bunch of actions). To do that, you can use Accounts global object. Just add this code anywhere on the client side (inside client folder):
Accounts.ui.config({
requestPermissions: {
google: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/youtube',
'https://www.googleapis.com/auth/youtube.upload'
]
},
requestOfflineToken: {
google: true
}
});
The next time you authorize with Google, you should see that the popup asks not only for basic information but for YouTube access. For more information about YouTube Google API scopes, see official docs.