2

I have a asp.net web api, that's been consumed by a ionic app.
This web api have some routes that need authorization and others that not.

is there anyway to configure the web api just to be consumed by the ionic app? Any help would be appreciated.

Thanks

1 Answer 1

5

This spreads in a wide scope. However irrespective of the back end API (Asp.net), you are asking how to authenticate an ionic app with back end API.

Basically u have main 3 options

1 - Using an existing Authentication implementation like OAuth2

basically you have to implement an Oauth2 server from your back end and have an ionic client to communicate with it

You will find some server libraries for .net in the OAuth2 web site

For client , you can use ng-cordova-oauth

2 - Let the Authentication handled by a 3rd party provider like (google)

  • What you can basically do it, let user to login through Ex: there google account,

  • send the api token to your back end api (in the first request)

  • Let the back end api validate the key with same provider

3 - Roll out your own authentication service

DONT :),

Try to implement a simple authentication service. But not the best way to go

HTH

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your response sameera207, I understand that I need to use tokens based authentication service, But definitely I have some routes that I need to access without any authentication, like my api/products or api/products route, I do not how to the security, so that only my Ionic apps, could access those. I dont want someone to point to servername/api/products in the browser and that he would be to se de info.
@albertolo, sorry for late reply, One workaround I can see is, when you generate a token, keep a record in the back end on which devise its issued to. By that way when the token hits the API, you can decide the request came from an ionic app or not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.