Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use firebase token authentication with a web api2 controller

I have a firebase authentication token that i am trying to pass to a web api controller. I am following this post here. stackoverflowpost

I have the bearer token in the $http request headers. angular

I took care of cors(unless I missed something). The end point in my api project is receiving the request with null headers. So I am trying to debug what is wrong but without any specific errors I am not sure where to look apiproject

like image 695
texas697 Avatar asked Dec 01 '15 02:12

texas697


People also ask

How do I use Firebase authentication token?

To do so securely, after a successful sign-in, send the user's ID token to your server using HTTPS. Then, on the server, verify the integrity and authenticity of the ID token and retrieve the uid from it. You can use the uid transmitted in this way to securely identify the currently signed-in user on your server.

Does Firebase use OAuth2?

Generate an access token The Realtime Database REST API accepts standard Google OAuth2 access tokens. The access tokens can be generated using a service account with proper permissions to your Realtime Database.

How do I get the Firebase refresh token?

Every time a user signs in, the user credentials are sent to the Firebase Authentication backend and exchanged for a Firebase ID token (a JWT) and refresh token. Firebase ID tokens are short lived and last for an hour; the refresh token can be used to retrieve new ID tokens.


1 Answers

You can get the value of an element "Authorization" in header by using following code:

  string firebaseAuthToken = string.Empty;
    firebaseAuthToken = actionContext.Request.Headers.GetValues("Authorization").First();
like image 151
Sachin Verma Avatar answered Oct 26 '22 14:10

Sachin Verma